question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass $ssl_client_s_dn to flask app

See original GitHub issue

My 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:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
tiangolocommented, Feb 2, 2019

Done! ✔️

I just finished a big refactor to be able to add this feature on top.

You can now add a file /app/nginx.conf and 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

0reactions
MiaMishcommented, Jan 13, 2019

Yes, that would be great.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found