Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streamlit does not work correctly behind a reverse proxy if a trailing slash is omitted #1139

Open
monchier opened this issue Feb 24, 2020 · 0 comments
Labels

Comments

@monchier
Copy link
Contributor

@monchier monchier commented Feb 24, 2020

Summary

When Streamlit is behind a reverse proxy, it won't work if a trailing slash is not included.

Steps to reproduce

Setup nginx with the following nginx.conf:

worker_processes  1;

events {
    worker_connections 1024;
}

http {
    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }

    server {
        listen 5000;
        server_name localhost;

        location /my_prefix/another {
            rewrite /my_prefix/another/(.*) /$1  break;
            rewrite /my_prefix/another /  break;
            proxy_pass http://localhost:8501;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
        }
    }
}

Run streamlit on localhost.

Access streamlit at http://localhost:5000/my_prefix/another

Expected behavior:

You can access Streamlit

Actual behavior:

Not able to access Streamlit. Path to static resources are broken. They miss a part of the rewrite rule:
Screen Shot 2020-02-24 at 2 16 38 PM

Additional information

  • Addign a trailing slash as http://localhost:5000/my_prefix/another/ fixes this problem.
  • This may show up with other reverse proxy than nginx.
  • A quick fix is to add a redirect rule to the address with the trailing slash.
@monchier monchier added the bug label Feb 24, 2020
@jrhone jrhone added the network label Apr 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.