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

In HTTPS Change of data source not working on Table and Dashboards #8160

Closed
3 tasks
srikanth-reddy-m opened this issue Sep 3, 2019 · 17 comments
Closed
3 tasks
Labels
!deprecated-label:bug Deprecated label - Use #bug instead

Comments

@srikanth-reddy-m
Copy link

srikanth-reddy-m commented Sep 3, 2019

supersetImage
A clear and concise description of what the bug is.

CodeBase: Master Branch

When trying to change superset data source from HTTPS it is trying to open Url in HTTP in which it is creating the error.

Error: Unsafe attempt to load URL, Domains, protocols, and ports must match

Expected results

It should load URL's with only HTTps
what you expected to happen.

Actual results

what actually happens.

Screenshots

![supersetImage](
supersetImage

)

If applicable, add screenshots to help explain your problem.

How to reproduce the bug

  1. Go to Superset sources and select Tables.
  2. Click on any source this will open that source
  3. Now click on Data Source drop-down and select change data source and select any data source.
  4. This will show error

Environment

(please complete the following information):

  • superset version: superset version
  • python version: python --version
  • node.js version: node -v
  • npm version: npm -v

Checklist

Make sure these boxes are checked before submitting your issue - thank you!

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

Add any other context about the problem here.

@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label #bug to this issue, with a confidence of 0.94. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@issue-label-bot issue-label-bot bot added the !deprecated-label:bug Deprecated label - Use #bug instead label Sep 3, 2019
@srikanth-reddy-m
Copy link
Author

This issue is solved, I have missed roxy_set_header X-Forwarded-Proto 'https' header setting in nginx.
If we are using nginx as a reverse proxy with https we have to add this header to flask-app builder to know schema information.

@syazshafei
Copy link

@srikanth-reddy-m Do you have problem when selecting the datasource?

@maltoze
Copy link
Contributor

maltoze commented Nov 22, 2019

@syazwan0913 This worked for me.

# superset/config.py
ENABLE_PROXY_FIX = True
PROXY_FIX_CONFIG = {"x_for": 1, "x_proto": 1, "x_host": 1, "x_port": 1, "x_prefix": 1

@syazshafei
Copy link

@maltoze what is the version of superset you are using?

@maltoze
Copy link
Contributor

maltoze commented Nov 22, 2019

@syazwan0913 I'm using 0.29.

I also change this in my code.

# superset/__init__.py
if app.config.get("ENABLE_PROXY_FIX"):
    from werkzeug.middleware.proxy_fix import ProxyFix

    app.wsgi_app = ProxyFix(app.wsgi_app, **app.config.get("PROXY_FIX_CONFIG"))

related #8117

@syazshafei
Copy link

@maltoze alright I got it. Thanks

@CaptainHoangLe
Copy link

CaptainHoangLe commented Apr 28, 2021

I am using superset ver 0.36 and having the same problem when i create an api get user info below
image
image

i have used all solutions of you but it don't work :(. Someone help me , thanks all

@syazshafei
Copy link

@CaptainHoangLe are you using Nginx? can share your configuration?

@CaptainHoangLe
Copy link

@CaptainHoangLe are you using Nginx? can share your configuration?

Dear bro ,this is my config nginx
image

@syazshafei
Copy link

You need to add this line inside your Nginx config
proxy_set_header X-Forwarded-Proto https;

Also in superset_config.py you must enable this:

ENABLE_PROXY_FIX = True
PROXY_FIX_CONFIG = {"x_for": 1, "x_proto": 1, "x_host": 1, "x_port": 1, "x_prefix": 1

@CaptainHoangLe
Copy link

CaptainHoangLe commented Apr 29, 2021

You need to add this line inside your Nginx config
proxy_set_header X-Forwarded-Proto https;

Also in superset_config.py you must enable this:

ENABLE_PROXY_FIX = True
PROXY_FIX_CONFIG = {"x_for": 1, "x_proto": 1, "x_host": 1, "x_port": 1, "x_prefix": 1

i have just done that but it can't help me to sloving this problem .i don't know where the error came from

@CaptainHoangLe
Copy link

image
it send request to https but response location is http

@syazshafei
Copy link

@CaptainHoangLe are you using Nginx? can share your configuration?

Dear bro ,this is my config nginx
image

Have you try to run without proxy_set_header X-Forwarded-For $remote_addr and proxy_set_header Host $http_host ?

Because mine having same problem as yours if using that config.

@CaptainHoangLe
Copy link

@CaptainHoangLe are you using Nginx? can share your configuration?

Dear bro ,this is my config nginx
image

Have you try to run without proxy_set_header X-Forwarded-For $remote_addr and proxy_set_header Host $http_host ?

Because mine having same problem as yours if using that config.

i have tried but nothing changed. Can i see your nginx config? thanks

@syazshafei
Copy link

Here is my working nginx config

worker_processes auto;

error_log /var/log/nginx/error.log error;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] $status '
    '"$request" $body_bytes_sent "$http_referer" '
    '"$http_user_agent"';

    access_log /var/log/nginx/access.log main;

    client_header_timeout 3m;
    client_body_timeout 3m;
    send_timeout 3m;

    client_header_buffer_size 1k;
    large_client_header_buffers 4 4k;

    gzip on;
    gzip_min_length 1100;
    gzip_buffers 4 8k;
    gzip_types text/plain;

    output_buffers 1 32k;
    postpone_output 1460;

    sendfile on;
    tcp_nopush on;

    tcp_nodelay on;

    client_max_body_size 200M;

    server_tokens off;
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";

    upstream backend {
        server IP;
    }

    server {
        listen 80;
        server_name _;
        return 301 https://$server_name$request_uri;
    }

    server {
        listen 443 ssl;
        server_name analytics.local;
        ssl_certificate /etc/nginx/ssl/ssl.crt;
        ssl_certificate_key /etc/nginx/ssl/ssl.key;

        underscores_in_headers on;

        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_read_timeout 300s;
            proxy_connect_timeout 300s;
            proxy_send_timeout 300s;
            proxy_pass http://backend;
            proxy_max_temp_file_size 0;
        }
    }
}

@CaptainHoangLe
Copy link

Here is my working nginx config

worker_processes auto;

error_log /var/log/nginx/error.log error;

events {
    worker_connections 1024;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    log_format main '$remote_addr - $remote_user [$time_local] $status '
    '"$request" $body_bytes_sent "$http_referer" '
    '"$http_user_agent"';

    access_log /var/log/nginx/access.log main;

    client_header_timeout 3m;
    client_body_timeout 3m;
    send_timeout 3m;

    client_header_buffer_size 1k;
    large_client_header_buffers 4 4k;

    gzip on;
    gzip_min_length 1100;
    gzip_buffers 4 8k;
    gzip_types text/plain;

    output_buffers 1 32k;
    postpone_output 1460;

    sendfile on;
    tcp_nopush on;

    tcp_nodelay on;

    client_max_body_size 200M;

    server_tokens off;
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";

    upstream backend {
        server IP;
    }

    server {
        listen 80;
        server_name _;
        return 301 https://$server_name$request_uri;
    }

    server {
        listen 443 ssl;
        server_name analytics.local;
        ssl_certificate /etc/nginx/ssl/ssl.crt;
        ssl_certificate_key /etc/nginx/ssl/ssl.key;

        underscores_in_headers on;

        location / {
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_read_timeout 300s;
            proxy_connect_timeout 300s;
            proxy_send_timeout 300s;
            proxy_pass http://backend;
            proxy_max_temp_file_size 0;
        }
    }
}

thank you, i got it. this reason is config in nginx not apply when i change.Once again I thank you very much for your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
!deprecated-label:bug Deprecated label - Use #bug instead
Projects
None yet
Development

No branches or pull requests

4 participants