Godaddy子域名配置
步骤1:配置域名的DNS##
-
点击[DNS区域文件]选项卡,跳转到DNS区域文件编辑页面
Paste_Image.png -
在[DNS区域文件]页面,点击[添加记录]按钮,显示添加弹窗
Paste_Image.png -
添加子域名
Paste_Image.png - 点击[完成]按钮,完成一个子域名的添加.
步骤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;
}
}
}
网友评论