我有麻烦build立一个URL重写和FastCGI的Nginx的组合。 fastcgi接口后面的应用程序服务器期望/ myapp /作为基本path。 我想在我的http://myserver.com/下访问
upstream appfcgi { server 127.0.0.1:6000; server 127.0.0.1:6001; server 127.0.0.1:6002; fair; } server { listen 80 default; server_name myserver.com; root /var/www; location / { rewrite ^(/.*)$ /myapp$1 last; } location /myapp/ { include /etc/nginx/fastcgi_params; fastcgi_intercept_errors on; fastcgi_pass appfcgi; }
无论我尝试什么,我总是得到显示的应用程序服务器的根path。 我记得我有麻烦,然后用Apache做同样的事情,但直到今天我还是试图用nginx来做。 任何帮助表示赞赏。 谢谢。
我不认为你在这里需要两个地点。 这是我的一个configuration:
location / { root /path.to.app/; index index.php index.html; rewrite ^/(.*)$ /index.php?query=$1 break; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /path.to.app/$fastcgi_script_name; include fastcgi_params; }