localhost:8000 的 svg-sprite 出现 404

你好。我正在运行一个新的 Discourse 实例,相关配置如下:

hostname =  localhost:8000
relative_url_root = /forum

部分资源无法加载。例如,以下链接返回 404 错误:

http://localhost:8000/forum/svg-sprite/localhost:8000/svg-2-ea6ff3f2981a98a7323fb5294880aa4255c98f87.js

但是,如果我将 URL 手动更改为 `/svg-sprite/localhost/…',它就能正常加载。

您为什么没有使用 80 端口?

不支持在非标准端口上发布。

因为我只在本地测试,并且 80 端口上还有其他服务。我最终找到了一个修复方法,只需在 nginx.conf 中添加以下内容:

rewrite /forum/(svg-sprite|user_avatar)/([^/]+):[0-9]+/(.*) /forum/$1/$2/$3;