我遇到了麻烦在我的 droplet 上设置目录的子域名(数字海洋):
我有我的 droplet 的域名 primarydomain.com ...我创建了一个目录 /livezilla/
例子:
primarydomain.com/livezilla
我想向此目录添加外部子域名(livezilla):
chat.myotherdomain.com.br
我有:/etc/nginx/sites-avaliable/primarydomain.com:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name primarydomain.com;
location / {
try_files $uri $uri/ /index.php?q=$uri&args;
}
}
和
/etc/nginx/sites-avaliable/chat.myotherdomain.com.br
server {
listen 80;
listen [::]:80;
server_name chat.myotherdomain.com.br;
root /usr/share/nginx/html/livezilla/;
index index.php index.html index.htm;
}
(在 /etc/nginx/sites-enabled 上有一份副本)
这chat.myotherdomain.com.br 有 A 记录在 DNS 中指向我的 droplet..
chat.myotherdomain.com.br 现在重定向到 myotherdomain.com.br 但 ping 显示我的 droplet ip。)):
怎么了?
答案1
这解决了我的问题。真是的。
server {
listen chat.myotherdomain.com.br:80;
server_name chat.myotherdomain.com.br;
root /usr/share/nginx/html/livezilla;
index index.php index.html index.htm;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
}
}