Setting up a reverse proxy for a couple sites, one of which requires the users IP for login purposes. The reverse proxy is configured with NGINX and hosted in a docker container, docker is running Linux 10 (Buster) and is on a windows machine. This code works, but doesn't pass the users IP:
server {
listen 80;listen [::]:80;
server_name your.domain.com;
location / {
proxy_pass http://Host IP:Port/;
proxy_buffering off;
}
}
When i add the headers it suddenly stops working, which doesn't really make much sense to me as i got the code snippets straight from NGINX's docs, this is how the code looks with the headers:
server {
listen 80;listen [::]:80;
server_name your.domain.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://Host IP:Port/;
proxy_buffering off;
}
}
When i restart the container, it instantly shuts down and i get this error message:
2020/11/13 20:17:58 [emerg] 1#1: invalid number of arguments in "proxy_set_header" directive in /etc/nginx/conf.d/admin.conf:6
nginx: [emerg] invalid number of arguments in "proxy_set_header" directive in /etc/nginx/conf.d/admin.conf:6
I've tried removing one of the headers but the result is still the same, when i remove both everything works as intended, been trying to find a fix for a couple hours to no avail so i hope that someone here can help me out.