Pass $ssl_client_s_dn to flask app
See original GitHub issueMy nginx.conf file looks like this:
uwsgi_read_timeout 300;
ssl_certificate /app/cert.pem;
ssl_certificate_key /app/key.pem;
ssl_password_file /app/password.pass;
ssl_client_certificate /app/client-ca.crt;
ssl_verify_client optional;
ssl_verify_depth 2;
include uwsgi_params;
uwsgi_param HTTP_X_DN $ssl_client_s_dn;
I want my Flask app to receive the HTTP_X_DN parameter, but cannot find how.
From looking around, I found its expected to reside in request.environ object of flask, but I don’t see any such key when printing the environ content.
For reference, request.environ.keys()) returns the following when sending a request via Postman:
dict_keys(['QUERY_STRING', 'REQUEST_METHOD', 'CONTENT_TYPE', 'CONTENT_LENGTH', 'REQUEST_URI', 'PATH_INFO', 'DOCUMENT_ROOT', 'SERVER_PROTOCOL', 'REQUEST_SCHEME', 'HTTPS', 'REMOTE_ADDR', 'REMOTE_PORT', 'SERVER_PORT', 'SERVER_NAME', 'HTTP_CONTENT_TYPE', 'HTTP_CACHE_CONTROL', 'HTTP_POSTMAN_TOKEN', 'HTTP_USER_AGENT', 'HTTP_ACCEPT', 'HTTP_HOST', 'HTTP_ACCEPT_ENCODING', 'HTTP_CONTENT_LENGTH', 'HTTP_CONNECTION', 'wsgi.input', 'wsgi.file_wrapper', 'wsgi.version', 'wsgi.errors', 'wsgi.run_once', 'wsgi.multithread', 'wsgi.multiprocess', 'wsgi.url_scheme', 'uwsgi.version', 'uwsgi.node', 'werkzeug.request'])
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Pass $ssl_client_s_dn from nginx/uwsgi to flask app
I want to pass on my client certificate DN if one exists. For that I defined the following nginx.conf : uwsgi_read_timeout 300; ssl_certificate ......
Read more >Running Your Flask Application Over HTTPS - Miguel Grinberg
The general idea is that when the client establishes a connection with the server and requests an encrypted connection, the server responds with ......
Read more >Secure flask app with self signed SSL certificate (flask HTTPS)
Here we will secure our flask web application with self signed SSL ... What you are about to enter is what is called...
Read more >How to Host a Flask Server With Gunicorn and HTTPS
In this tutorial, we will be setting up a Flask server using Gunicorn ... We will be using a self-signed certificate on your...
Read more >HTTPS and trust chain in Flask - Rand/eng works
This method requires the web server to be bound to a certificate and key. Such data can be used by the connecting client...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Done! ✔️
I just finished a big refactor to be able to add this feature on top.
You can now add a file
/app/nginx.confand it will be used instead of the generated one.You can check the docs here: https://github.com/tiangolo/uwsgi-nginx-flask-docker#overriding-nginx-configuration-completely
Yes, that would be great.