nginx configure domain name, no port

I purchased the domain name on Tencent Cloud and pointed the domain name to the host IP address in domain name management. Port 8006 was specified in tomcat instead of the default 8080.

In this way, you can use the domain name: 8006/project name to access the website, but this also seems to leak the port number.

Remove the port number after the domain name and use nginx to implement port forwarding.

1. Register domain name information on Tencent Cloud or Alibaba Cloud, and resolve and direct it to the corresponding IP    

2. Configure parameters in nginx’s conf/nginx.conf:

   #Configure background service address

    upstream webserver {
        server 127.0.0.1:9527;
    }

    server {         listen 80; #Configure port information         server_name www.9527.com; #Configure domain name information         location / {             root /data/wx/web;             index index.html index.htm;         }





        location ^~/api {             proxy_pass http://webserver; #upstram webserver             proxy_connect_timeout 30s;             proxy_read_timeout 20s;             proxy_send_timeout 20s;             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_set_header X-Forwarded-Proto $scheme;           }     }









3. Only need the above settings, start nginx or reload the configuration ./nginx -s reload

Guess you like

Origin blog.csdn.net/wangguoqing_it/article/details/131083387