for example, when I first used nginx, I changed it according to the default configuration and wanted to do a simple hello world..
The expected effect ofis that typing http://aaa.com:8081/main.html, in the browser address bar should open a specific page. But the reality is so cruel that the browser simply says "unable to access this site".
therefore, I would like to ask what went wrong and how to solve it. Why is it that when I change the server_name in the configuration to localhost, the access is normal?
the configuration file code is as follows: nginx.conf
-sharpuser nobody;
worker_processes 1;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
-sharp
server {
listen 8081;
server_name aaa.com; -sharplocalhost
location / {
root html;
index main.html index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include servers/*;
}
actual effect:
1. Enter localhost:8081/main.html is normal
2.aaa.com:8081/main.html