When the user enters the url http://localhost:8000/Hello, I need to redirect him to http://localhost:8081/Hello.
Here is my attempt on the deploy.conf file:
server {
listen 8000;
location /Hello {
include uwsgi_params;
uwsgi_pass localhost:8081/Hello;
}
}
But when I check nginx with: sudo nginx -t
I get this error:
nginx: [emerg] invalid host in upstream "localhost:8081/Hello" in /projects/challenge/deploy.conf
Please any help?
2
Answers
the uwsgi_pass should point to the uswgi server so your config file would look like this:
The error is due to the improper format of the
uwsgi_pass
directive. Theuwsgi_pass
directive expects a URL or a Unix socket path as its argument, not a complete URL with a path.Try this way:
In this configuration, you’re instructing Nginx to proxy requests that match the
/Hello
path to the uWSGI server running onlocalhost:8081
.Keep in mind that this Nginx configuration assumes that your uWSGI server is properly configured and running on
localhost:8081
.After making this change, you should reload Nginx for the changes to take effect: