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>
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>
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>
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>
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.