nginx 常用配置

nginx 正常配置
$host之后加上端口号,如$host:81

server {
    listen 81;
    server_name localhost;
    location / {
        proxy_set_header Host $host:81;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_pass http://127.0.0.1:9380;
}

nginx 去掉URl前缀

location /prod-api {
        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_set_header X-NginX-Proxy true;
        proxy_pass  http://planproxy;
        rewrite ^/prod-api/(.*) /$1 break;
       }

你可能感兴趣的:(nginx 常用配置)