嗨,我习惯于与Apache和Mod代理,我的服务器configuration看起来有点像这样,我redirect所有传入的请求
ServerName example.com
DocumentRoot / var / www / trunk / public
ServerName www.example.com
redirect永久/ http://mentoredge.com
ProxyPreserveHost打开
ServerName o.example.com
ProxyPass / http:// localhost:8000 /
ProxyPassReverse / http:// localhost:8000 /
在这里,我将所有的input请求路由到本地主机的8000端口。
我已经迁移到Nginx现在即时尝试设置相同的o.example.com这个代理。 有人可以向我解释如何做到这一点。
server { listen 80; server_name o.example.com; location / { proxy_pass http://localhost:8000; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; client_body_buffer_size 128k; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; proxy_buffers 32 4k; proxy_set_header X-Forwarded-Server $host; } }
这是我已经添加到我的conf,但这似乎并没有做我所期望的。 我在这里错过了什么。 事情是我把它作为一个单独的.conf文件存储,并且在所有其他服务器信息之前先被添加。
这是我使用的
location / { proxy_read_timeout 2000; proxy_next_upstream error; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_max_temp_file_size 0; proxy_pass http://localhost:8000; break; }