Godaddy子域名配置
步驟1:配置域名的DNS##
-
點(diǎn)擊[DNS區(qū)域文件]選項(xiàng)卡汹押,跳轉(zhuǎn)到DNS區(qū)域文件編輯頁面
-
在[DNS區(qū)域文件]頁面,點(diǎn)擊[添加記錄]按鈕吆视,顯示添加彈窗
-
添加子域名
- 點(diǎn)擊[完成]按鈕,完成一個(gè)子域名的添加.
步驟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;
}
}
}