Nginx和端口80有问题

我有一个应用程序在192.168.101.120:8080 。 现在我想通过端口80上的nginx运行它。 看看nginx.conf

 user nginx; worker_processes 1; error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; 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; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; # Load config files from the /etc/nginx/conf.d directory # The default server is in conf.d/default.conf include /etc/nginx/conf.d/*.conf; server { listen 80; server_name myserver.com; location / { root /some/public/folder; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://192.168.101.120:8080; } } } 

但端口80显示我默认的nginx页面。 我可以改变listen 80; listen 8081; 一切都会好起来的 哪里不对?

你可能有一个default.conf或类似的nginx正在加载。

尝试这个

 grep -r 80 /etc/nginx/* 

如果我是正确的,那可能会给你一些提示。

您的server_name定义与您使用的URL不匹配,因此您收到了错误的虚拟主机。 记住,当server_namemysserver.com时, http://www.myserver.com : mysserver.com