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:
Some news:

I limited the concerned location to public root exclusively, adding an equal sign before "/". And it raised an error on "nginx -t" validation: it entered in conflict with a location block about PHP globally declared in /usr/local/apps/nginx/etc/conf.d/common:

Code
# Pass the INDEX.PHP script to FastCGI server listening on 127.0.0.1:9178
location = / {
    fastcgi_read_timeout 3600;
    try_files $uri /index.php /index.html @maintenance;
    fastcgi_pass    unix:/usr/local/apps/php73/var/php73_9001.sock;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param  SCRIPT_NAME    $fastcgi_script_name;
    include        fastcgi_params;
}

Commenting this block above, my own below added for the subdomain as Extra Config, passed:
Code
# pass requests to wsgi server
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://localhost:8000;
}

With this new location block, it works: when I navigate to http://test.mydomain.com, it well pass the request to the back-end WSGI server (Gunicorn) and the page computed by Python is well returned! So, good news, since the overall process works :)

But, but, I don't want to restrict the forwarding from Nginx to Gunicorn for the public root only. I would like to submit all requests to the underlying Gunicorn server as it should be to serve a WSGI-based app.

Why it doesn't work without the "=", despite the fact the "location / {}" block I showed in first pass is the one advised everywhere talking about Nginx as reverse proxy for a WSGI server serving a Python Flask app?

Also, should I uninstall PHP to prevent conflict, knowing I don't need PHP unless for phpMyAdmin and if Webuzo needs it?

So, what from this point?
How to redirect all requests to Gunicorn?

What do you think?

Good night (2:10 AM here)  :neu:

-----------------------
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 392591 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.011