problem description
By configuring nginx, you can set an ip address to access different web applications through different ports, but after a long time, the relationship between port numbers and applications becomes blurred.
For example, http://120.79.79.xx:9001 and foreign.xxx.xin, although both websites point to the same website, the latter is obviously more interesting than the former. At the same time, in website seo, the latter also has a higher weight than the former.
elementary knowledge
Top-level domain name: .com.cn
Second-level domain name: sina.com, baidu.com, in which baidu and sina are second-level domain names.
Third-level domain name: zhidao is the third-level domain name in zhidao.baidu.com.
Basic steps
Set address resolution
Configure nginx listening
Configure nginx jump
Create address resolution
Alibaba Cloud used by the author, after logging in to the Alibaba Cloud background, adds a record and fills the third-level domain name into the host record. For details, please refer to the following figure.
Configure nginx
Modify the default file in/etc/nginx/sites-avilable, and the complete code is as follows:
server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html/wordpress; index index.php index.html index.htm index.nginx-debian.html ; server_name www.xxxx.xin; location / { try_files $uri $uri/ =404; } location ~ .php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } location ~ /.ht { deny all; }} # Service2server {listen80; server_name foreign.xxx.xin; location / { proxy_pass http://120.79.xx.xx:9000/; }}
Both services are listening on the same port 80, but the server_name of service 2 is consistent with the newly set address resolution. Then set proxy_pass to forward the information obtained from port 80 to port 9000.
Copyright Description:No reproduction without permission。
Knowledge sharing community for developers。
Let more developers benefit from it。
Help developers share knowledge through the Internet。
Follow us