nginx domain binding domain, nginx domain binding port


I. nginx domain binding Domain nginx bind multiple domains can also write multiple domain rules in a configuration file, but also can create multiple domain configuration files separately, I generally build a file for each domain for ease of management, some similar domains can also be written in a total configuration file. I. Writing one file per domain First opennginx Domain Name Profile Storage Directory:/usr/local/nginx/conf/servers , If you want to bind a domain namewww.itblood.com then create a file in this directory:www.itblood.com.conf Then write rules in this file, as if:

server{
    listen 80;
     server_name www.itblood.com;  #Binding Domain
     index index.htm index.html index.php;  #default file
     root /home/www/itblood.com;  #website root directory
     include location.conf;  # Call other rules, also remove
}

   Then restart the nginx server, and the domain name is bound successfully nginx server restart command: /etc/init.d/nginx restart Second, a file more than one domain name The rules for adding multiple domains to a file are the same, just write down the above individual domains repeatedly, e.g.

server{
    listen 80;
     server_name www.itblood.com;  #Binding Domain
     index index.htm index.html index.php;  #default file
     root /home/www/itblood.com;  #website root directory
     include location.conf;  # Call other rules, also remove
}
 
server{
    listen 80;
     server_name msn.itblood.com;  #Binding Domain
     index index.htm index.html index.php;  #default file
     root /home/www/msn.itblood.com;  #website root directory
     include location.conf;  # Call other rules, also remove
}

   Third, the domain name without www plus 301 hops If the domain name without www to add a 301 jump, that is also the same as binding the domain name, first binding the domain name without www, just do not have to write the site directory, but a 301 jump, such as.

server
{
    listen 80;
    server_name itblood.com;
    rewrite ^/(.*) http://www.itblood.com/$1 permanent;
}

Four, add 404 pages

Add 404 pages, can be added directly in it, such as:

server{
    listen 80;
     server_name www.itblood.com;  #Binding Domain
     index index.htm index.html index.php;  #default file
     root /home/www/itblood.com;  #website root directory
     include location.conf;  # Call other rules, also remove
    error_page 404 /404.html;
}

nginx domain binding port

server {
    listen  80;  
     server_name taqing.me www.taqing.me;  ##, bind the domain name
    location / {  
          proxy_pass http://127.0.0.1:8000;   ## Specify port number 8000
    }  

Recommended>>
1、The Advanced Python Tutorials are coming on strong
2、Weekend AI class neural network overview code section
3、Xin Guobin Promote manufacturing industry to accelerate the development of digitalization networking and intelligence
4、How many ways do you copy files under Windows with Python
5、A robot with a face also wants to have a family

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号