美文网首页
07 godaddy子域名配置

07 godaddy子域名配置

作者: 风之舞者II | 来源:发表于2017-01-22 16:00 被阅读0次

Godaddy子域名配置

步骤1:配置域名的DNS##

  1. 点击[DNS区域文件]选项卡,跳转到DNS区域文件编辑页面


    Paste_Image.png
  2. 在[DNS区域文件]页面,点击[添加记录]按钮,显示添加弹窗


    Paste_Image.png
  3. 添加子域名


    Paste_Image.png
  4. 点击[完成]按钮,完成一个子域名的添加.

步骤2:配置Nginx

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    
    log_format  main  '【$subdomain】 - $remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    sendfile        on;
    keepalive_timeout  65;


    server {
        set $subdomain '';
        if ($host ~* (\b(?!www\b).+)\.shishangblog.com) {
            set $subdomain $1;
        }

        server_name  bags.shishangblog.com;
        listen       80;
        access_log logs/$2-access.log main;

        location / {
            proxy_pass http://127.0.0.1:8080;
            proxy_redirect default;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $http_connection;
            proxy_set_header domain_name $subdomain;
            
            access_log logs/subdomain.log main;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

    server {
        set $subdomain '';
        if ($host ~* (\b(?!www\b).+)\.shishangblog.com) {
            set $subdomain $1;
        }
        
        server_name  shishangblog.com;
        listen       80;
        
        location / {
            proxy_pass http://127.0.0.1:8080;
            proxy_redirect default;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $http_connection;
            proxy_set_header domain_name $subdomain;
            
            access_log logs/domain.log main;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
}

参考资料

添加指向一个 IP 地址的子域名

相关文章

网友评论

      本文标题:07 godaddy子域名配置

      本文链接:https://www.haomeiwen.com/subject/ijkobttx.html