Nginx
Nginx(docker容器)後面的Owncloud沒有記錄遠端客戶端IP
出於某種原因,我在 Nginx 反向代理後面的 Owncloud 容器沒有記錄遠端客戶端 IP,而是記錄 Nginx IP。請在下面查看我的 Nginx 配置文件。我嘗試了多種解決方案來修改 Nginx proxy_set_headers 指令,但均未成功。
Nginx 伺服器正確地將標頭髮送到 Owncloud 伺服器:
"HTTP Headers Information": { "HTTP Request": "GET \/apps\/configreport\/report HTTP\/1.1", "X-Real-IP": "CLIENT_IP", "X-Forwarded-For": "CLIENT_IP", "X-Forwarded-Proto": "https", "X-Forwarded-Host": "mydomain:port", "X-Forwarded-Ssl": "on",
但是,
REMOTE_ADDR
Apache 環境中的 var 被設置為 Nginx 伺服器 IP。我嘗試了在 Owncloud docker 映像中載入的 RemoteIP 模組,但 Nginx IP 仍然被記錄。
有任何想法嗎?
Nginx.conf:
server { listen 8989 ssl; listen [::]:8989 ssl; server_name _; add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive"; include /config/nginx/ssl.conf; client_max_body_size 0; server_tokens off; more_clear_headers Server; location / { proxy_pass http://owncloud:8080; include /config/nginx/proxy.conf; } }
代理.conf:
client_body_buffer_size 128k; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; send_timeout 5m; proxy_read_timeout 240; proxy_send_timeout 240; proxy_connect_timeout 240; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Ssl on; proxy_redirect http:// $scheme://; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_cache_bypass $cookie_session; proxy_no_cache $cookie_session; proxy_buffers 32 4k; proxy_headers_hash_bucket_size 128; proxy_headers_hash_max_size 1024;
通過將 Apache 的日誌格式更改為
LogFormat "%{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\ " combine