Why does nginx not work when it is running?

83 views Asked by At

I meet a strange issue, I installed nginx via command yum install nginx -y on CentOS8 stream, and I checked its status via command sudo netstat -plutn | grep nginx, it runs.

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      9962/nginx: master

And the nginx.conf file is following

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    include /etc/nginx/conf.d/*.conf;

}

In folder conf.d, there is only one config file called cx.conf

server {
        listen 80;
        return 403;
}

I thought I will get 403 error if I visit this server via its IP, but actually, I got Empty reply from server.

What I have done

  1. Checked if the ports are allowed, and yes, they are all allowed, I can get some response like this Connection to **.***.***.*** port 80 [tcp/http] succeeded!

  2. Checked another application which is not running on nginx, and yes, there's an application which is running via Docker container on this server. I can visit it via ip:8080.

  3. Uninstall and reinstall nginx, and yes. But it is still the same.

  4. Set SELinux disabled

It seems that nginx is running, but it doesn't work. Please help. Thank you.

0

There are 0 answers