Home > Backend Development > PHP Tutorial > Nginx configuration cannot be accessed except port 80

Nginx configuration cannot be accessed except port 80

WBOY
Release: 2016-07-28 08:26:00
Original
2030 people have browsed it

Today I configured an nginx virtual host to listen to a custom port 8118. After restarting nginx, I can’t access the connection through my computer browser:
Check the listening port:
netstat -lnt
Returns that port 8118 has been monitored
Thinking it is the firewall, check the firewall status:
/etc/init.d/iptables status
But nothing was output, then I stopped the firewall

<code>/etc/init.d/iptables <span>stop</span></code>
Copy after login

My computer still couldn’t access it, and then I logged in to this computer
wget 127.0.0.1:8118
Returns 403, indicating that it can be accessed. It's really weird.
Because my account is a non-root account, I accidentally added sudo when checking the firewall to return the open port of the firewall, and the firewall was always open. In other words, the reason is because the firewall does not have open ports.
The next step is easy:

<code>vi /etc/sysconfig/iptables</code>
Copy after login

See that the firewall has opened ports 22, 3306 and 80, add a new port

<code><span>-A</span> INPUT <span>-m</span> state <span>--</span>state <span>NEW</span><span>-m</span> tcp <span>-p</span> tcp <span>--</span>dport <span>8118</span><span>-j</span> ACCEPT</code>
Copy after login

Restart the firewall: /etc/init.d/iptables restart

Then why nothing happens when executing the iptables script output, unlike other scripts that report errors without permissions. I probably looked at the iptables startup script and there is a line in it:

<code><span># only usable for root</span>
[ <span>$EUID</span> = <span>0</span> ] || <span>exit</span><span>4</span></code>
Copy after login

It means that only root can call the iptables startup script. I am really ignorant

').addClass('pre -numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above has introduced the nginx configuration that non-80 ports cannot be accessed, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template