小编Ami*_*min的帖子

使用 nginx 将真实的远程 IP 转发到代理服务器

为了隐藏我的网站 IP,我在另一个 VPS 上用 nginx 代理了主服务器。我正在尝试将访问者的真实 IP 发送到我的网站,这是我在 conf.d 文件夹中的配置:

proxy_cache_path  /etc/nginx/cacheddata  levels=1:2   keys_zone=staticfilecache:180m  max_size=500m;
proxy_temp_path /etc/nginx/cacheddata/temp;
proxy_connect_timeout 30;
proxy_read_timeout 120;
proxy_send_timeout 120;

#IMPORTANT - this sets the basic cache key that's used in the static file cache.
proxy_cache_key "$scheme://$host$request_uri";

upstream wordpressapache {
        #The upstream apache server. You can have many of these and weight them accordingly,
        #allowing nginx to function as a caching load balancer 
        server 127.0.0.1:8080 weight=1 fail_timeout=120s;
}
server {
      listen 80;
      server_name XXXXXX.com;
      access_log off;
      error_log …
Run Code Online (Sandbox Code Playgroud)

nginx reverse-proxy x-forwarded-for

5
推荐指数
3
解决办法
3万
查看次数

标签 统计

nginx ×1

reverse-proxy ×1

x-forwarded-for ×1