2017-02-10 2 views
0

5つのウェブサイトを設定しようとしている。とcdn。 しかしwww。それはうまく動作するように動作します tho cdn。私はそれらをコピーしたのと同じファイルを持っています、すべての権限はフォルダのために同じです。 それぞれのサブドメインはそれぞれのファイルwwwmydomaincomとcdnmydomaincomにあり、configは同じです。diffrenceだけがserver_nameです。作品はwww.mydomain.comを持っている残りの部分はsomesubdomain.mydomain.comを持っていると彼らは404を投げる。Nginxはいくつかのサブドメインでは404を返すが、他のドメインでは返さない。

私はubuntuサーバー16.04.1でNginxを使用します。

追加

location/{ 
    try_files $uri.html; 
} 

とサブドメインは (作品のような、今では設定isent)htmlページがうまく表示さしかし...すべての資産、CSS、JS、画像や他のものはそう404を取得しますそれは純粋なhtmlページです。

configの下にはwww.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; 
    } 
} 

答えて

0

をcdn.mydomain.com合うように変更し、私はもののこの種を学びたい理由は、これがあります。

あなたは明らかにファイルを探す必要があります。

誰もがこのような状況に入ると、ルートフォルダに表示されるように忘れないでください。

location/{ 
    try_files $uri $uri/ $uri.html @rewrite; 
} 
関連する問題