把nginx.conf删除所有的注释项目,变简单如下:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
在server节点中,增加一个访问规则
location ~ .*.action$ {
proxy_pass http://192.168.88.87:8080;
#以内4行复制粘贴就可以
proxy_redirect off;
proxy_set_header Host $host;#可以让后端拿到真实的客户端ip地址
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}