在server中添加3个字段,然后再程序中通过获取Header中的X-Forwarded-For取出真实客户端IP

    server {
        listen       8090;
        server_name  localhost;
        root html/h5;

        location /api/registerAfter/ {
                proxy_pass http://127.0.0.1:2022/;
        }
        location /callback/ {
                proxy_pass http://127.0.0.1:5022/;
        }

        location / {
            try_files $uri $uri/ /;
            index  index.html index.htm;
        }
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

 }
Copyright © 运维知识库 all right reserved,powered by Gitbook文件修订时间: 2023-09-19 10:45:38

results matching ""

    No results matching ""