我已经设置并运行了 RAILS 应用程序(graylog2),并且以下配置使其适用于根位置:
server {
server_name www.mydomain.com;
location / {
gzip off;
uwsgi_modifier1 7;
include uwsgi_params;
uwsgi_pass 127.0.0.1:3033;
}
}
但我想将我的应用程序放在一个路径中,例如:/graylog2
我更改了我的配置,并添加了它 uwsgi_param SCRIPT_NAME /graylog2
,但它不起作用。
server {
server_name www.mydomain.com;
root /opt/graylog2-web-interface/public/;
location /graylog2 {
gzip off;
include uwsgi_params;
uwsgi_param SCRIPT_NAME /graylog2;
uwsgi_modifier1 7;
uwsgi_pass graylog2;
}
location / {
autoindex on;
}
}
我正在使用 Ubuntu 12.04.1 LTS、nginx/1.1.19 和从 git 编译的最新 uwsgi
Nginx 访问日志
127.0.0.1 - - [16/Mar/2013:12:26:31 +0700] "GET /graylog2/ HTTP/1.1" 404 609 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0"
127.0.0.1 - - [16/Mar/2013:12:26:31 +0700] "GET /assets/error.css HTTP/1.1" 200 458 "http://localhost/graylog2/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0"
127.0.0.1 - - [16/Mar/2013:12:26:31 +0700] "GET /assets/errorlogo.png HTTP/1.1" 200 11097 "http://localhost/assets/error.css" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0"
没有 nginx error.log
uwsgi.log
[pid: 2321|app: 0|req: 15/25] 127.0.0.1 () {42 vars in 963 bytes} [Sat Mar 16 12:24:04 2013] GET /graylog2/ => generated 609 bytes in 31 msecs (HTTP/1.1 404) 7 headers in 237 bytes (0 switches on core 0)
针对我的设置,配置 nginx + uwsgi 的正确方法是什么?
答案1
你试过这个吗?我已经在 gitlab 中使用了这个技巧,它解决了同样的问题...
location /graylog2 {
gzip off;
include uwsgi_params;
uwsgi_param X-Url-Prefix http://www.mydomain.com/;
uwsgi_modifier1 7;
uwsgi_pass graylog2;
}