配置的例子如下:
server {
listen 8037;
server_name localhost;
#kzjtrans-web
location /kzjtrans-web/ {
proxy_pass http://localhost:8036/kzjtrans-web/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 120s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
}
#kzjtrans-h5
location / {
root /data/kzjtrans-web;
index login.html;
}
}
总结如下:
(1)若是外部访问,监听端口8037必须有对外开放。
(2)前端访问接口的url只需使用location配置的部分"/kzjtrans-web/" + 服务接口,无需在前面加ip和端口号