how to forward 80 port to domain using nginx - nginx

i used centos 7 nginx
i want forward 80 port to domain
can use nginx or iptables or what ?
I searched, but everyone asks about forwarding Port to Port only
thank you

You can edit Server tag in nginx.conf file
server {
listen Server-IP:80;
...
}
This will route Server-IP:80 request to the Nginx server.

Related

Odoo how to keep the port number in the address bar Nginx

my home have static IP but have with port 80,443 Block, I use port fowarding in router 8069 > odoo server port 443 > rever proxy 8069
SSL is ok, I'm using certbot over DNS, everytime I need to access odoo is,
hit https://erp.example.com:8069
Return [ERROR 503] https://erp.example.com/web
which nginx remove the port automatically,
hit https://erp.example.com:8069/web/login
Return [Success] https://erp.example.com:8069/web/login
when put full address port_number/ it does the work
is there any solution let nginx not to redirect what I input at address bar? I need keep the custom port
this isn't what I need, Nginx trying redirect to what I entered 8069 to 443 port, which 443 port has block by ISP

How can I redirect traffic from Port 80 to Port 443 using UFW?

I use Ubuntu Server 18.04 and wish to forward/redirect traffic from port 80 to port 443 (https).
I want to do this as I have SSL on NGINX(port 80) and a Flask app running on Gunicorn on port 443. I can't make NGINX proxy requests as the app isn't in a virtualenv.
I wish to use UFW. How can I do this?
Redirecting http to https traffic is not the purpose of a firewall like ufw.
You should redirect the requests within NGINX as follows:
server {
listen 80;
server_name example.org;
return 301 https://example.org$request_uri;
}
... where 80 is the http port, example.org is your domain, and 301 indicates the browser that the resource is accessible at the other place.

I have another app (not nginx) running on localhost. How do I setup nginx so it runs on a different local IP?

I have an application that is not nginx running on localhost. I want to setup a server on nginx but one that isn't running on localhost so I can use them simultaneously.
My /etc/hosts file would ideally look something like this:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 a.website.loc
127.0.0.2 another.website.loc
127.0.0.1 is the route running on an app that is not nginx.
127.0.0.2 is the route I want nginx running on.
My nginx.conf would ideally look something like this:
server {
# listen ???;
server_name another.website.loc;
root /path/to/another_website;
}
So how do I set this up on nginx? Or would I set it up on localhost too but running on a different port?
Thanks! PS I am running on a macOS Sierra.
To listen another IP you should have another network card with the other IP.
But you have to options:
Modify your OS hosts file to assign another name to your server, and then on nginx
server {
server_name yournameonhostsfile
use another port (as you stated on your question):
server {
listen 8000;

nginx listen directive confusion

I am trying to configure nginx i m trying to find how listen directive in server block works.
suppose i have this config:
server {
listen 192.168.11.12:80;
}
Does it mean nginx will listen for requests on port 80 which is coming from ip: 192.168.11.22 . or does it mean it will listen on ip 192.168.11.12 and on port 80. I searched for docs but they simply mention how server block works.
The second one, it will listen on that ip and port.

No response from port 8080 in apache2/Ubuntu10.10

I have a computer at home running Ubuntu 10.10. I am trying to make a server and host my own website, and I am running a LAMP (Linux, Apache, MySql, PHP) server. But my IPS blocks incoming traffic on port 80. To get around this, I want my server to take HTTP requests from port 8080, in addition to port 80. But after I tried to add port 8080 to the accepted ports file, my browser cannot access it. It says "The server at mywebsite.com is taking too long to respond.". Does anyone know why it is timing out and not returning the webpage, or how I can fix this? Here is what I've done so far:
The port.conf file contains:
NameVirtualHost *:80
Listen 80
Listen 8080
The apache2.conf file contains:
# Include the virtual host configurations:
Include sites-enabled/
NameVirtualHost *:80
NameVirtualHost *:8080
The sites-available/default file contains:
<VirtualHost *:80 *:8080>
ServerAdmin webmaster#localhost
Lastly I restarted apache:
$: /etc/init.d/apache2 restart
All this, as far as I can tell, should add port 8080 to for HTTP requests. When I type in "localhost" or "localhost:8080" into the web browser, it returns my website. If I type in "mysite.com" or "mysite.com:80", the site also works. But my website does not work when I search for "mysite.com:8080"; rather it times out. The reason "mysite.com:80" works is because I am accessing the site from within my local network, so I don not need to go through the modem, which would block port 80. Does anyone know why this is not working?
FIX: I'm dumb and forgot to add port 8080 on the list of acceptable ports on my Ubuntu firewall.
Have you had a look at the requests with wireshark or something like that? localhost will be going through the loopback device, and I'm guessing that when you request mysite.com the request is going out over a real network device. Check whether the request is getting back in again from your network - port 8080 might be blocked somewhere else.

Resources