Issue accessing plotly dash behind nginx - nginx

I have a dash plotly running on a VM with ip address 192.168.8.3 on port 5050. Locally, I can access the dashboard using the url http://192.168.8.3:5050.
Now I am trying to enable access via Nginx on http://myserver.com/dashboard/devs. However, when i try access it, in the browser console there is some files not found:
GET http://myserver.com/assets/header.css?m=1597279663.0
GET http://myserver.com/assets/typography.css?m=1597279663.0
This is my nginx configuration:
server {
server_name myserver.com;
location /dashboard/devs {
rewrite ^/(dashboard/devs)/(.*) /$2 break;
proxy_pass http://192.168.8.3:5050;
proxy_set_header X-Real_IP $remote_addr
...
proxy_set_header Host $http_host;
proxy_redirect off;
}
}

Finally it was resolved using flask to redirect "/" requests to "/dashboard/devs/". The nginx configuration was left untouched.

Related

No host name in browser Nginx

I'm having a problem with nginx server.
When I deploy it and type my hostname in the broker window it will find the page, but it will display IP, not the host name. I tried few things and it always fails. It is strange because I used this before and worked.
I can add that I'm using it as a reverse proxy.
DNS correctly redirects to IP.
But no hostname is shown.
I tried this on AWS EC2 and on digital ocean.
My basic conf is:
server {
listen 80;
listen [::]:80;
server_name hostname.com;
location / {
proxy_pass http://api:8000/index;
proxy_set_header Upgrade $server_name;
proxy_set_header Host $server_name;
}
}

flask oidc auth callback redirects to http instead of https

This is my first attempt to deploy a plotly dash python web app. I followed below tutorials to get going
digital ocean flask app with gunicorn and nginx
Okta authentication for flask app using OpenIdConnect
The app runs fine on an ec2 instance with nginx and gunicorn all in docker containers. The redirect to okta for authentication and back works fine (using ec2 instance public ip)
After setting redirect for domain name via aws load balancer (HTTPS) it started failing complaining 404 as url scheme returned was http instead of https.
First i added OVERWRITE_REDIRECT_URI config with https which fixed incorrect redirect uri problem on okta side
Then tried ProxyFix and all options in below SO posts but after redirect to /authorization-code/callback?code=<long code value>, the response always comes back with http://<my_website_name>/<page> instead of https
Make Flask's url_for use the 'https' scheme in an AWS load balancer without messing with SSLify
X-Forwarded-Proto and Flask
I'm stuck at this point, what am i missing here?
Thanks
nginx conf.d/conf
upstream app_server {
server dash:8050;
}
server {
listen 80;
server_name _;
location / {
try_files $uri #proxy_to_app;
}
location #proxy_to_app {
gzip_static on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_buffering off;
proxy_redirect off;
proxy_pass http://app_server;
}
}

nginx reverse proxy for kibana

I am using this part in nginx config file
location ~ ^/kibana(.*) {
rewrite /kibana/(.*) /$1 break;
proxy_pass http://core-services-local-nginx-ingress-controller.kube-system:80;
proxy_redirect off;
proxy_set_header Host "kibana-service-local";
}
but the issue is ,when i do localhost/kibana/ it is redirecting to localhost/app/kibana and displaying 4o4 not found .
why it is happening? how to resolve this issue?I want kibana dashboard to come when hitting localhost/kibana/.
set the server.basePath setting in kibana.yml to /kibana.

Nginx preserve $request_uri

I'm not sure if the behavior I want is actually possible natively with nginx but here goes.
I have a server running on port 81 with the following nginx config:
CONFIGURATION OF SERVER1 NGINX
server {
listen 81;
server_name SERVER_DNS_NAME;
location /server1 {
proxy_pass http://127.0.0.1:8084/;
proxy_set_header Host $host;
}
location / {
proxy_pass http://127.0.0.1:8084;
proxy_set_header Host $host:$server_port;
}
}
I have another server running on port 82 with similar configuration. Now what'd i'd like to do is be able to visit them both from port 80 with just different uris.
For example: URL/server1 would take me to the first server, and URL/server2 would take me to the second.
CONFIGURATION OF NGINX LISTENING ON PORT 80
server {
listen SERVER_IP:80;
location /server1{
proxy_set_header Host $host;
http://SERVER_IP:81;
}
location /server2 {
proxy_pass http://SERVER_IP:82;
proxy_set_header Host $host;
}
This works fine when I go to URL/server1. I am successfully routed to the main page on server1. However as soon as I click any of the links present on the page on server1 I get a 404. This is because the site tries to go to URL/some_subdir_of_server1 (for which there is no mapping) rather than doing URL/server1/some_subdir_of_server1. Is this behavior doable? If so how?
Thanks!
Be careful with trailing slashes: in your example, you have
proxy_pass http://SERVER_IP:81/; which will set the proxy URL to root /

Too many redirects while setting up gogs with nginx

I am setting up gogs on nginx server.I also have cpanel/apache hosted on the same server.I am redirecting my gogs call using .htaccess from cpanel.My nginx configuration is
server {
listen 9800;
server_name <my_domain>;
proxy_set_header X-Real-IP $remote_addr; # pass on real client IP
location / {
proxy_pass http://localhost:8000;
}
}
It is working fine if i am using direct ip from browser but when i am using domain it throwing ERR_TOO_MANY_REDIRECTS error on browser.

Resources