EndSound's Life

【技術】Nginx反向代理

server {
    listen       80;
    server_name  localhost;

    location / {
        proxy_redirect off;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass <url>
    }
}

以上範本的意思是,關閉代理轉導,設定轉過去後相關header,如host、x-real-ip、x-fowarded-for,轉request至url

Syntax:	proxy_redirect default;
        proxy_redirect off;
        proxy_redirect redirect replacement;
Default: proxy_redirect default;
Context: http, server, location
Syntax:	proxy_pass_header field;
Default: —
Context: http, server, location
Syntax:	proxy_pass URL;
Default: —
Context: location, if in location, limit_except

參考:
Nginx.org

發表迴響