Home  >  Q&A  >  body text

Configure nginx. The website can only be accessed smoothly by adding a port after the domain name or IP.

The project is deployed in tomcat.

nginx configuration:

server {
        listen       8083 ;
        server_name  域名;

        location / {

            index  index.html index.htm index.jsp;
            #proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
            proxy_pass http://127.0.0.1:8081/;
        }                       
}

It cannot be accessed directly through the domain name. After adding the 8081 port, you can access it smoothly. The direct IP port method is also available.

After just changing the domain name behind server_name to localhost, and restarting nginx, the direct domain name can be accessed, but after more than ten minutes it fails again, and I still need to add a port. Strange.

淡淡烟草味淡淡烟草味2712 days ago481

reply all(2)I'll reply

  • 巴扎黑

    巴扎黑2017-05-16 17:29:02

    The problem has been solved because there is a firewall outside nginx, which forwards all requests through port 80 to port 8083.
    After adding -A INPUT -p tcp -m tcp --dport 8083 -j ACCEPT to the firewall, you can always access the website.

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 17:29:02

    Your nginx is configured to listen on port 8083: try changing the sentence "listen 8083" to "listen 80"

    reply
    0
  • Cancelreply