1、已经安装了nginx
2、修改tomcat端口号为10081(可随意)
3 修改nginx的nginx.config 如下:
upstream apiserver {
ip_hash;
server 121.41.76.50:10081;
}
upstream consoleserver {
ip_hash;
server 121.41.76.50:10081;
}
server {
listen 80;
server_name:121.41.76.50;
#charset koi8-r;
#access_log logs/host.access.log main;
location /console {
proxy_pass http://consoleserver;
#proxy setting
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;
#size limits
client_max_body_size 50m;
client_body_buffer_size 256k;
}
location /down {# /后面紧跟down 不能有空格
proxy_pass http://consoleserver;
#proxy setting
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;
#size limits
client_max_body_size 50m;
client_body_buffer_size 256k;
}
location /api {
proxy_pass http://apiserver;
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 50m;
client_body_buffer_size 256k;
}
}
/usr/local/nginx/sbin/nginx -t 检测配置文件是否配置成功
/usr/local/nginx/sbin/nginx -s reload 热重启