Nginx can be started successfully but cannot be accessed.

01-01-2024

environment

Alibaba Cloud Server Ubuntu 16.04.3 LTS

I got a learning demo myself, and built the front-end separation of vue+elementui+spring boot. Deploy the project to the server. Install nginx, in order to avoid conflict, change the port to 8001, start nginx, and find that it cannot be accessed!

(Recommended tutorial: nginx tutorial)

Find out what the problem is

1. First check whether nginx configuration is correct.

Nginx -t # Check whether the nginx configuration is correct or switch to the sbin directory under the installation directory of nginx and execute:./Nginx-t.

2. Check whether nginx started successfully.

Ps -ef | grep nginx # view the nginx port

After the execution, it was found that there was no problem with nginx configuration, and the startup was successful! Then, I have a hunch that the port is not open, because Alibaba Cloud's server is used, and the security group needs to be configured first.

3. Configure Alibaba Cloud Security Group, that is, release the corresponding port for other hosts to access.

I configured port 8001 in nginx, so I let go of the port in the range of 8000-9000 here. But the access is still not available, it should be that the server itself has not opened the port 8001.

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

(1) Check whether the firewall is turned on.

Sudo ufw status # If the output: Status: inactive means that the firewall has been closed, it is reasonable to say that all ports should be open, and it is ok to connect to a remote server with your own host.

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

Ufw disable # Turn off the firewall Ufw enable # Open the firewall

(2) If a firewall is turned on for security, a certain port can be released separately.

See if the port is open.

telnet ip port # telnet 59.110.155.32 8001

I tested it on Alibaba Cloud server, and the results are as follows:

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

ps:

View all open ports

Command one

Netstat -a # View all service ports

Order two

Nmap+ip address #: nmap 127.0.0.1

Many times you can't quit after telnet, and sometimes ctrl+c can't quit.

At this time, execute: ctrl+] first and then enter quit at the telnet command line to exit.

Release the port so that other hosts can access it.

If all the above are successful, it must be accessible!

Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us