I have been trying to set up NGINX for the first time and I need to enable port forwarding from 80 to 8080 for my website. However, after many attempts I have obtained nothing. Here is my latest attempt:
I followed the steps here accordingly: https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-virtual-hosts-server-blocks-on-ubuntu-12-04-lts--3
The difference is the fact that my nginx.conf file contains:
server{
listen 80;
server_name myWebsiteName;
access_log /home/path_to_site/access.log;
error_log /home/path_to_site/error.log;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Is this the right file content? Am I using the wrong tutorial?
Thanks!
The example you provided contains some mistakes:
A fixed example could be:
server{
listen 80;
server_name myWebsiteName;
access_log /home/path_to_site/access.log;
error_log /home/path_to_site/error.log;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
In this example all incoming requests on port 80 will be proxied to port 8080 on this host.
Despite this being possible, is this really the solution you are looking for? Is it possible to change the listening port for the application that you are proxying to?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With