nchan icon indicating copy to clipboard operation
nchan copied to clipboard

nchan_authorize_request: Can't pass $remote_addr to backend

Open fsanchez2020 opened this issue 5 years ago • 0 comments

I'm trying to pass the $remote_addr but always is empty and I tried a lot of settings, so i write this to check if anyone is having the same problem

NginX 1.19.2 Nchan 1.2.7 AWS EC2 Linux

Current setup:

server {
	listen 127.0.0.1:16384;

	root /var/www;
	
	location = /auth {
		fastcgi_pass unix:/etc/php/var/run/usocket;
		
		fastcgi_param SCRIPT_FILENAME /var/www/auth.php;
		fastcgi_param DOCUMENT_ROOT /var/www;
		
		include fastcgi_params;
	}
}

server {
	server_name 127.0.0.1:80;

	root /var/www;

	location ~ /conn/(\w+)$ {
		nchan_authorize_request /auth;

		nchan_pubsub websocket;

		nchan_channel_id $1;

		nchan_store_messages off;
		nchan_message_buffer_length 15;
		nchan_message_timeout 2s;
	}

	location = /auth {
		allow 127.0.0.1;
		deny all;

		proxy_pass http://127.0.0.1:16384/auth;

		proxy_pass_request_body off;

		proxy_set_header Content-Length "";
		proxy_set_header X-Subscriber-Type $nchan_subscriber_type;
		proxy_set_header X-Publisher-Type $nchan_publisher_type;
		proxy_set_header X-Prev-Message-Id $nchan_prev_message_id;
		proxy_set_header X-Channel-Id $nchan_channel_id;
		proxy_set_header X-Original-URI $request_uri;
		proxy_set_header X-Forwarded-For $remote_addr;
	}
}

fsanchez2020 avatar Dec 10 '20 04:12 fsanchez2020