Home > Operation and Maintenance > Nginx > nginx can start successfully but cannot be accessed

nginx can start successfully but cannot be accessed

王林
Release: 2020-11-04 16:48:13
forward
13335 people have browsed it

nginx can start successfully but cannot be accessed

Environment

Alibaba Cloud Server Ubuntu 16.04.3 LTS

I made a demo for learning and built vue elementui spring boot with front-end and back-end separation . Deploy the project to the server. After installing nginx, in order to avoid conflicts, I changed the port to 8001, started nginx, and found that I could not access it!

(Recommended tutorial: nginx tutorial)

Find the problem

1. First check whether the nginx configuration is correct

nginx -t   #查看nginx配置是否正确  也可以切换到nginx的安装目录下的sbin目录下,执行: ./nginx -t
Copy after login

2. Check whether nginx starts successfully.

ps -ef | grep nginx  #查看nginx端口
Copy after login

After execution, it is found that there is no problem with the nginx configuration and the startup is successful! Then, I had a hunch that the port was not open because I was using an Alibaba Cloud server and needed to configure a security group first.

3. Configure the Alibaba Cloud security group, that is, open the corresponding port so that other hosts can access the port 8001 I configured in

nginx can start successfully but cannot be accessed

nginx, so Open the ports in the 8000-9000 range here. But the access still doesn't work. It should be that the server itself has not opened port 8001.

4. Check whether the port corresponding to the server is open

(1) Check whether the firewall is open

sudo ufw status   # 如果输出:Status: inactive 说明防火墙已经关闭,按理说端口应该都是开放的,用自己的主机连接远程服务器都是可以的
Copy after login

You can turn off the firewall, open all ports, and execute the following command

ufw disable   #关闭防火墙
ufw enable  # 开启防火墙
Copy after login

(2) If the firewall is turned on for security reasons, you can open a certain port separately

Check whether the port is open

telnet ip port  # telnet 59.110.155.32 8001
Copy after login

I tested it on the Alibaba Cloud server, and the result As follows:

nginx can start successfully but cannot be accessed

The above picture shows that port 8001 is not released and port 8080 is released;

ps:

View all open ports

Command 1

netstat -a # 查看所有服务端口
Copy after login

Command 2

nmap + ip地址 # 如:nmap 127.0.0.1
Copy after login

Many times telnet cannot be exited, and ctrl c sometimes cannot exit;

This First execute: ctrl ] and then enter quit on the telnet command line to exit.

Open the port so that other hosts can access it.

If all of the above are successful, you must be able to access it!

The above is the detailed content of nginx can start successfully but cannot be accessed. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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