以下为nginx多服务配置示例,仅供参考。
server {
listen 28888;
listen 20888;
server_name 192.168.5.1 192.168.5.104;
access_log /home/logs/nginx/swallow.log;
error_log /home/logs/nginx/swallow.err.log;
error_page 500 502 503 504 403 /error.html;
error_page 404 /404.html;
proxy_intercept_errors on;
if ($request_method !~* GET|HEAD|POST) {
return 400;
}
location / {
#proxy_pass http://192.168.5.1:18080;
index index.htm index.html index.jsp;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
if ($host ~* "user.jz.com") {
proxy_pass http://192.168.5.104:8071;
}
if ($host ~* "admin.jz.com") {
proxy_pass http://192.168.5.104:8070;
}
if ($host ~* "www.jz.com") {
proxy_pass http://192.168.5.104:8072;
}
proxy_pass http://192.168.5.1:8888;
}
}
以上就介绍了nginx 多服务配置,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。