Search code examples
pythonnginxflaskuwsgi

restapi with Nginx and uwsgi not passing headers info


I have a flask app that runs fine with just uwsgi as a service on port 5000. I am trying to use Nginx to proxy https to port 5000 in the back end. It is hitting my app, but my app requires auth tokens to be sent on the header and I am not getting it when proxying through Nginx. However if I change the URL to port 5000 the headers are passed. How can I configure Nginx to pass everything to the app? This app does GET,PUSH,PUT,DELETE and users will be sending not only the header, but json data as well.

##################### NGINX CONFIG #####################
    location /customer/ {
            include uwsgi_params;
            uwsgi_pass unix:///var/www/html/cisco/cisco.sock;
    }
    

##################### UWSGI CONFIG #####################        
[uwsgi]
module = wsgi:application

master = true
processes = 5

uid=apache
gid=apache

buffer-size = 32768

http = 0.0.0.0:5000

req-logger = file:/var/log/uwsgi/cart-req.log
logger = file:/var/log/uwsgi/cart-err.log

chmod-socket = 666
vacuum = true
socket = cisco.sock

die-on-term = false

py-autoreload = 1

Solution

  • I asume we are talking about request headers. In this case you can use this directive uwsgi_pass_request_headers on; in your location-block:

      location /customer/ {
                include uwsgi_params;
                uwsgi_pass_request_headers on;
                uwsgi_pass unix:///var/www/html/cisco/cisco.sock;
        }
    

    However on is the default value so if not turned off anywere else the headers as well as the request-body should be sent to your Python application.

    What are your header names? Are you able to update your questions with the header names or even better a example HTTP request in curl format?