Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set up the third-level domain name in nginx

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge points of this article "how to set up a third-level domain name in nginx", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to set up a three-level domain name in nginx" article.

Problem description

By configuring nginx, you can set an ip address to access different web applications through different ports, but the relationship between the port number and the application becomes blurred after a long time.

Such as http://120.79.79.xx:9001 and foreign.xxx.xin, although both URLs point to the same website, the latter is obviously literal and much better than the former. At the same time, in the website seo, the latter also has a higher weight than the former.

Basic knowledge

Top-level domain name: .com .cn

Second-level domain name: baidu.com sina.com, where baidu and sina are second-level domain names

Third-level domain name: zhidao.baidu.com, where zhidao is the third-level domain name

Basic steps

Set up address resolution

Configure nginx snooping

Configure nginx Jump

Create address resolution

For the Aliyun used by the author, after logging in to the Aliyun backend, add a record and enter the third-level domain name into the host record. For more information, please see the figure below.

Configure nginx

Modify the default file in / etc/nginx/sites-aviablable, 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 } # Service 2server {listen 80; 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.

The above is the content of this article on "how to set up a three-level domain name in nginx". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report