Welcome Guest. Please Login or Register  


You are here: Index > Webuzo > General Support > Topic : Nginx as reverse proxy for WSGI server



Normal Mode | Print  

Nginx as reverse proxy for WSGI server
erile
Group: Member
Post Group: Working Newbie
Posts: 64
Status:
OK, Solved with this extra conf for the subdomain:

Code
# pass all requests to website root to wsgi erver
location = / {
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    #proxy_pass http://unix:/home/admin/test/wsgi_test.sock;
    proxy_pass http://127.0.0.1:8000;
}

# pass all requests to any path to wsgi erver
location / {
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    #proxy_pass http://unix:/home/admin/test/wsgi_test.sock;
    proxy_pass http://127.0.0.1:8000;
}

Some explanations; may help someone a day...

The first location block is just about "/", strictly, and I disabled the PHP location which was in conflict (see my previous post above).

The second location block is above any request whatever the path (it's the reason why it worked for the images inside page, but not the html page at root itself). If there's a matching route served by the backend server, it will serve it through the underlying Python code. If there's no matching route, we get the behavior provided by our app or the Gunicorn 404 if nothing provided.

Later, I'll add a location block to serve static files, but the heart of the issue is solved: website root was ignored (don't know why) and in conflict with a PHP's location block (declared by Webuzo in common file) when not.

-----------------------
OpenVZ VPS, CentOS 7, Webuzo Premium / Desktop and full-stack dev w/ C, C++, Python, Perl, javascript...
IP: --   


Threads
 erile   Nginx as reverse proxy for WSGI server (6 Replies, Read 392593 times)
    |--  erile   Hmm, I suspect...   on August 4, 2019, 8:50 pm
    |--  erile   This weird effect...   on August 4, 2019, 9:05 pm
    |--  erile   Some news: I...   on August 5, 2019, 12:12 am
    |--  erile   UPDATE: I have...   on August 5, 2019, 12:45 am
    |--  erile   OK, Solved with...   on August 5, 2019, 11:16 am
    |--  naresh335   thanks for this...   on November 25, 2022, 2:58 am

« Previous    Next »

Normal Mode | Print  



Users viewing this topic
1 guests, 0 users.


All times are GMT. The time now is May 14, 2026, 4:16 am.

  Powered By AEF 1.0.8 © 2007-2008 Electron Inc.Queries: 10  |  Page Created In:0.401