0
因此,我試圖設置5個網站,所有在相同的域只是與不同的子域名等www。和cdn。 但www。工作正常,因爲它應該 tho cdn。沒有,它得到了我剛把它們複製過來的相同文件,這些文件夾的所有權限都是相同的。 我有他們自己的文件等wwwmydomaincom和cdnmydomaincom中的每個子域和配置是相同的,只有差異是server_name。該作品的文件得到www.mydomain.com其餘的得到somesubdomain.mydomain.com,他們扔404。Nginx返回404的一些子域名,但不爲其他人
我使用的Nginx的Ubuntu的服務器16.04.1。
新增
location/{
try_files $uri.html;
}
和子域顯示HTML頁面罰款(目前其配置isent喜歡的作品之一) 但是...每一項資產,CSS,JS,圖像或其他事情就這麼404這是一個純粹的HTML頁面。
的配置下是完全相同的配置爲www.mydomain.com但經過修改以適應cdn.mydomain.com
server {
listen 80;
server_name cdn.domain.com;
location /.well-known/acme-challenge {
default_type "text/plain";
root /storage/webserver/certbot;
}
#Forces all other requests to HTTPS
location/{
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
server_name cdn.domain.com;
ssl_certificate /etc/letsencrypt/live/cdn.domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/cdn.domain.com/privkey.pem;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_prefer_server_ciphers on;
ssl_ciphers EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA512:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:ECDH+AESGCM:ECDH+AES256:DH+AESGCM:DH+AES256:RSA+AESGCM:!aNULL:!eNULL:!LOW:!RC4:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS;
ssl_session_cache shared:TLS:2m;
# OCSP stapling
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8;
# Set HSTS to 365 days
add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains';
root /storage/webserver/cdn.domain.com;
index index.html index.php;
location @rewrite {
rewrite^$uri.php last;
try_files $uri =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+?\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include fastcgi.conf;
try_files $uri =404;
}
rewrite ^(/.*)\.html(\?.*)?$ $1$2 permanent;
#rewrite ^/(.*)/$ /$1 permanent;
error_page 404 /404.php;
error_page 500 503 502 504 /error/40x.php;
location =/error/40x.html {
internal;
}
}