Hi all,
I am currently struggling to setup the nginx proxy on AWS EC2.
Here is my config file:
'''
upstream bokeh {
server 127.0.0.1:5006;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /etc/keys/fullchain.pem;
ssl_certificate_key /etc/keys/privkey.pem;
root /var/www/html/simview;
proxy_buffering off;
server_name localhost;
access_log /var/log/simview_access.log;
error_log /var/log/simview_error.log debug;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/ubuntu/simview/simview.sock;
include uwsgi_params;
uwsgi_pass unix:/home/ubuntu/simview/simview.sock;
}
location /plot/ {
rewrite /plot/(.*) /$1 break;
proxy_pass http://bokeh$uri;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$server_port;
}
location /plot/static {
alias /home/ubuntu/simview/static;
}
}
'''
On the AWS EC2 instance I have allowed inbound ports HTTP/80 and HTTPS/443. I even created ELB with Listeners SSL/443/TCP and HTTP/80/HTTP.
Now error I get is 'ERR_TOO_MANY_REDIRECTS' with above conf file. The 'rewrite' rule is to pass the request arguments to proxy server.
If I comment out the following lines:
rewrite /plot/(.*) /$1 break;
proxy_redirect off;
then I get 'Failed to connect to Bokeh server Error: Lost websocket connection' with the following output in the Nginx access log (nothing in the error log):
The Nginx access file (the first needs no proxy and is successful, the second required a proxy and not successful):
'''
172.31.42.90 - - [20/Feb/2018:09:57:54 +0000] "PROXY TCP4 172.31.42.90 172.31.42.90 33975 80" 400 182 "-" "-"
172.31.31.211 - - [20/Feb/2018:09:57:51 +0000] "PROXY TCP4 172.31.31.211 172.31.31.211 13216 80" 400 182 "-" "-"
'''
I appreciate if someone could help me or put me in the right direction.
Regards
Aso
I am currently struggling to setup the nginx proxy on AWS EC2.
Here is my config file:
'''
upstream bokeh {
server 127.0.0.1:5006;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /etc/keys/fullchain.pem;
ssl_certificate_key /etc/keys/privkey.pem;
root /var/www/html/simview;
proxy_buffering off;
server_name localhost;
access_log /var/log/simview_access.log;
error_log /var/log/simview_error.log debug;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/ubuntu/simview/simview.sock;
include uwsgi_params;
uwsgi_pass unix:/home/ubuntu/simview/simview.sock;
}
location /plot/ {
rewrite /plot/(.*) /$1 break;
proxy_pass http://bokeh$uri;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:$server_port;
}
location /plot/static {
alias /home/ubuntu/simview/static;
}
}
'''
On the AWS EC2 instance I have allowed inbound ports HTTP/80 and HTTPS/443. I even created ELB with Listeners SSL/443/TCP and HTTP/80/HTTP.
Now error I get is 'ERR_TOO_MANY_REDIRECTS' with above conf file. The 'rewrite' rule is to pass the request arguments to proxy server.
If I comment out the following lines:
rewrite /plot/(.*) /$1 break;
proxy_redirect off;
then I get 'Failed to connect to Bokeh server Error: Lost websocket connection' with the following output in the Nginx access log (nothing in the error log):
The Nginx access file (the first needs no proxy and is successful, the second required a proxy and not successful):
'''
172.31.42.90 - - [20/Feb/2018:09:57:54 +0000] "PROXY TCP4 172.31.42.90 172.31.42.90 33975 80" 400 182 "-" "-"
172.31.31.211 - - [20/Feb/2018:09:57:51 +0000] "PROXY TCP4 172.31.31.211 172.31.31.211 13216 80" 400 182 "-" "-"
'''
I appreciate if someone could help me or put me in the right direction.
Regards
Aso