Why can't nginx in centos be accessed? Did I miss something?

Source: Internet
Author: User
Tags nginx host
Background I installed a minimal centos7 in virtualbox and then used another source yum to install nginx Host ip Address: 192.168.31.146centos bridge ip192.168.31.158 host hosts add address: 192.168.31.158cent.com to test that nginx has been started, show run...Background
  • Onvirtual boxInstall a minimalcentos 7
  • Other sourcesyumInstallednginx
  • Host ip Address:192.168.31.146
  • centosBridge ip192.168.31.158
  • Host hosts add address:192.168.31.158 cent.com
Test
  • nginxStarted. running is displayed.
  • nginxConfiguration Filedefault.confAs follows:
  • nginx -tDisplay normal
  • /usr/share/nginx/htmlThere is an html file by default.
  • Hostping cent.comCan be pinged. The ip address is 158.
  • There is nothing in the nginx log.
Problem
  • Host accesshttp://cent.comInaccessible
  • Why can't I access it? Did I miss something ??
Solution
  • It is indeed a firewall question. Thanks @ _ Zhao for answering this question. I forgot the firewall!
  • For centos7firewalld, I saidiptablesWhy ..
  • Firewalld is installed and enabled by default. To access nginx, run the following command:
    firewall-cmd --permanent --add-service=http
    firewall-cmd --permanent --zone=trusted --add-port=80/tcp
  • For other commands, refer to firewalld introduction.

Reply content:Background
  • Onvirtual boxInstall a minimalcentos 7
  • Other sourcesyumInstallednginx
  • Host ip Address:192.168.31.146
  • centosBridge ip192.168.31.158
  • Host hosts add address:192.168.31.158 cent.com
Test
  • nginxStarted. running is displayed.
  • nginxConfiguration Filedefault.confAs follows:
  • nginx -tDisplay normal
  • /usr/share/nginx/htmlThere is an html file by default.
  • Hostping cent.comCan be pinged. The ip address is 158.
  • There is nothing in the nginx log.
Problem
  • Host accesshttp://cent.comInaccessible
  • Why can't I access it? Did I miss something ??
Solution
  • It is indeed a firewall question. Thanks @ _ Zhao for answering this question. I forgot the firewall!
  • For centos7firewalld, I saidiptablesWhy ..
  • Firewalld is installed and enabled by default. To access nginx, run the following command:
    firewall-cmd --permanent --add-service=http
    firewall-cmd --permanent --zone=trusted --add-port=80/tcp
  • For other commands, refer to firewalld introduction.

@ Savokiss
FirstcentosTry to use$curl http://127.0.0.1Command to access nginx.
If you can obtainnginx.
Then, the problem basically lies in the firewall,centos 7Firewall usagefirewalld.
So, you needfirewalldAllow80Port.
For specific commandsgoogle.
Hope to solve your problem.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.