Reputation:
I have a small mini blog flask application. I execute this application like this:
$ gunicorn gunluk:app -p gunluk.pid -b 0.0.0.0:8000
I may access it like this:
But what I'd like to do is access site without specifying port name:
List of the current ip tables rules:
$ sudo iptables -nvL
Chain INPUT (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
62 7092 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8000
593 67706 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:5000
3631 3641K ACCEPT all -- enp1s0 * 0.0.0.0/0 0.0.0.0/0
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8000
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
655 74798 ACCEPT all -- * lo 0.0.0.0/0 0.0.0.0/0
2790 322K ACCEPT all -- * enp1s0 0.0.0.0/0 0.0.0.0/0
Also port forwarding settings in the router interface are as follows:
Interface Protocol Input Port Output Port Server IP Adress Name Status
nas_8_35 TCP 5000-5000 5000-5000 192.168.1.2 5000 Active
nas_8_35 TCP 8080-8080 8080-8080 192.168.1.2 web2 Active
nas_8_35 TCP/UDP 8000-8000 8000-8000 192.169.1.2 8000 Active
nas_8_35 TCP/UDP 80-80 80-80 192.168.1.2 http Active
I don't have a static ip, I use a free dynamic dns service with a dynamic ip address.
Upvotes: 0
Views: 1320
Reputation: 1525
it's a nginx
thing to handle.
server {
listen 80; # listen onport 80
server_name server_domain_or_IP; #requests to this domain or ip
location / {
include proxy_params;
proxy_pass http://unix:<fullpath-to-your-project>.sock;
}
}
this is reversing all traffic for server_name:80
to your app's url:port
and you can create a daemon
for your Gunicorn
to automatically run on system restarts.
Upvotes: 1