I’m using a supserset installation in virtual enviroment, gunicorn, nginx and apache since most of my sites in my server use apache. I’m trying to use Oauth2 with EntraID but the redirect_uri returns in http instead desired https. Looking on internet I found that most of the time ENABLE_PROXY_FIX=True
solves the problem but not in my case:
Nginx settings:
server {
listen 9999;
server_name domain.com;
location = /favicon.ico { access_log off; log_not_found off; }
location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn_superset.sock;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# Eliminamos esta línea porque Apache ya configura este encabezado
proxy_set_header X-Forwarded-Proto https;
}
}
Apache settings:
<IfModule mod_ssl.c>
<VirtualHost *:443>
SSLEngine on
ServerAdmin [email protected]
ServerName example.com
ProxyPreserveHost On
ProxyPass / http://localhost:9999/
ProxyPassReverse / http://localhost:9999/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLCertificateFile 'DIRECTORY'
SSLCertificateKeyFile 'DIRECTORY'
Include 'DIRECTORY'
#RequestHeader set X-Forwarded-Proto "https"
#RequestHeader set X-Forwarded-Ssl "on"
Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
Header always set X-Frame-Options DENY
Header always set X-Content-Type-Options nosniff
</VirtualHost>
</IfModule>
<VirtualHost *:80>
ServerName example.com
Redirect permanent / https://example.com/
</VirtualHost>
Apache superset settings
ENABLE_PROXY_FIX=True
SQLALCHEMY_DATABASE_URI = 'DATABE'
AUTH_TYPE = AUTH_OAUTH
OAUTH_PROVIDERS = [
{ 'name':'Alephsub0-EntraID',
'token_key':'access_token', # Name of the token in the response of access_token_url
'icon':'fa-sign-in', # Icon for the provider
'remote_app': {
'client_id':'ClienID', # Client Id (Identify Superset application)
'client_secret':'ClientSecret', # Secret for this Client Id (Identify Superset application)
'server_metadata_url':'url/.well-known/openid-configuration',
'client_kwargs':{
'scope': 'User.Read' # Scope for the Authorization
},
}
}
]
# Will allow user self registration, allowing to create Flask users from Authorized User
AUTH_USER_REGISTRATION=True
# The default user self registration role
AUTH_USER_REGISTRATION_ROLE = "Public"
SESSION_COOKIE_SAMESITE='None'
SESSION_COOKIE_HTTPONLY=False
SESSION_COOKIE_SECURE=True
# Proxy fix configuration
PROXY_FIX_CONFIG = {
'x_for': 1,
'x_proto': 1,
'x_host': 1,
'x_port': 1,
'x_prefix': 1
}
Any suggestion?
Use ENABLE_PROXY_FIX=True
. Headers in apache and nginx