nginx

20th August 2020 at 2:19pm
Load Balancer Reverse Proxy Web Server

使用 nginx 的一些经验纪录。

include directive

nginx 的 include directive 可以用通配符,通配符甚至可以在中间(这是 Bash 能力吧?):

include /usr/local/services/*/nginx.conf;

反向代理配置示例

server {
    listen          80;
    server_name     fm-api.oa.com;

    location /static/ {
        root    /usr/local/services/radio_api_server-1.0;
    }

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_pass http://127.0.0.1:13001;
        proxy_redirect off;
    }
}

设的几个 header 重要,但是还不清楚具体含义和作用。