我已经build立并运行了一个RAILS应用程序(graylog2),下面的configuration使它适用于根目录:
server { server_name www.mydomain.com; location / { gzip off; uwsgi_modifier1 7; include uwsgi_params; uwsgi_pass 127.0.0.1:3033; } }
但我想把我的应用程序放在一个path,例如: /graylog2
我改变了我的configuration,添加了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和最新的uwsgi编译的git
Nginx access.log
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)
什么是正确的方式来configurationnginx + uwsgi我的设置?
你有试过吗? 我用gitlab的这个技巧,它解决了同样的问题…
location /graylog2 { gzip off; include uwsgi_params; uwsgi_param X-Url-Prefix http://www.mydomain.com/; uwsgi_modifier1 7; uwsgi_pass graylog2; }