编辑nginx.conf文件,如下:
upstream mywebs {
ip_hash;
server 192.168.1.11:8088; #要转发去的地址和端口
}
server {
listen 8088;
server_name localhost;
location ~ ^/nginx_status {
stub_status on; #Nginx状态监控配置
access_log off;
allow 127.0.0.1; #设置为可访问该状态信息的ip
deny all;
}
}
server {
listen 8088;
server_name localhost;
location ~ ^/nginx_status {
stub_status on; #Nginx状态监控配置
access_log off;
allow 127.0.0.1; #设置为可访问该状态信息的ip
deny all;
}
location / {
proxy_pass http://mywebs;
proxy_redirect off;
proxy_set_header Host $host:8088; #这里的端口要和listen的值一样
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 100m;
access_log off;
}
proxy_pass http://mywebs;
proxy_redirect off;
proxy_set_header Host $host:8088; #这里的端口要和listen的值一样
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 100m;
access_log off;
}
}