1. cd /etc/nginx/
    2. vim default.conf

    示例配置:
    第 12 ~ 14 行是反向代理的实现。前端访问路径中带有 /amt/prod/amt时会命中此条规则,通过 proxy_pass属性将请求转发至真正的接口服务器。

    1. server {
    2. listen 1995;
    3. server_name localhost;
    4. #access_log /var/log/nginx/host.access.log main;
    5. location / {
    6. root /home/nginx_servers/1995;
    7. index index.html index.htm;
    8. }
    9. location ^~ /amt-prod/amt/ {
    10. proxy_pass http://123.57.1.19:9080;
    11. }
    12. error_page 500 502 503 504 /50x.html;
    13. location = /50x.html {
    14. root /usr/share/nginx/html;
    15. }
    16. }