【发布时间】:2018-10-25 19:54:31
【问题描述】:
我是一个 nginx 的菜鸟(以及 apache 和 php ...)
我有这个可以正常工作的烧瓶应用程序:
http://127.0.0.1:5000
以及外部来自http://myhost.com:5000
我想使用来自myhost.com/rest_1
为其他人腾出空间休息,例如 myhost.com/rest_2 .. 3 等等。
该应用位于/opt/rest_1
并使用它的 /static 文件夹中的一些资源,例如 css 和 jquery。
我有这个/etc/nginx/sites-available/rest_1.conf
server {
listen 80;
listen [::]:80;
server_name myhost.com;
server_name_in_redirect off;
location /rest_1 {
rewrite ^/rest_1(.*) /$1 break;
proxy_pass http://127.0.0.1:5000/;
}}
它是指向已启用网站的链接。
nginx 重新启动并重新加载,没有错误。
其他配置是安装时的默认配置。
当我尝试连接时
myhost.com/rest_1
我可以看到一个不完整的页面部分工作,查看 nginx 日志:/var/log/nginx/error.log:
*8 open() "/usr/share/nginx/html/static/w3.css" failed (2: No such file or directory), client: xx.xx.xx.xx, server: myhost.com, request: "GET /static/w3.css HTTP/1.1", host: "myhost.com", referrer: "http://myhost.com/rest_1"
所以,我很清楚 '/usr/share/nginx/html/' 是从其他地方获得的......并且该文件夹也应该有一个正确的名称(我是菜鸟!!)
如何告诉引擎重定向到正确的路径/opt/rest_1
取回所有/静态功能?
操作系统:ubuntu 服务器 16.04
nginx:1.10.3
谢谢。
【问题讨论】:
标签: nginx url-redirection proxypass