2017-09-15 1 views
0

언어 당 하나의 도메인을 갖고 싶은 프로젝트가 있습니다. 따라서 내 사이트는 동일한 디렉토리를 가리키고 있지만, 어떤 이유로 내 도메인 중 하나가 다른 도메인으로 리디렉션되고 있습니다.nginx 두 사이트 하나의 디렉토리

설명해주십시오. example.com example.org

example.org는 example.com과 동일한 디렉토리를 가리 킵니다.

내가 example.org를 방문

는, 나는 example.com

문제는 내가 두 도메인에 LetsEncrypt SSL을 사용하는 경우 나도 몰라로 리디렉션.

실마리가 있습니까? 여기

는 달리 매우 간단합니다, 내 nginx를 파일

example.com

# FORGE CONFIG (DOT NOT REMOVE!) 
include forge-conf/example.com/before/*; 

server { 
    listen 443 ssl http2; 
    listen [::]:443 ssl http2; 
    server_name example.com; 
    root /home/forge/example.com; 

    # FORGE SSL (DO NOT REMOVE!) 
    ssl_certificate /etc/nginx/ssl/example.com/xxx/server.crt; 
    ssl_certificate_key /etc/nginx/ssl/example.com/xxx/server.key; 

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
    ssl_ciphers 'XXXXXX-$' 
    ssl_prefer_server_ciphers on; 
    ssl_dhparam /etc/nginx/dhparams.pem; 

    add_header X-Frame-Options "SAMEORIGIN"; 
    add_header X-XSS-Protection "1; mode=block"; 
    add_header X-Content-Type-Options "nosniff"; 

    index index.html index.htm index.php; 

    charset utf-8; 

    # FORGE CONFIG (DOT NOT REMOVE!) 
    include forge-conf/example.com/server/*; 

    location/{ 
     try_files $uri $uri/ /index.php?$query_string; 
    } 
    location ~ /(public/mail-signature/.*)$ { 

    } 

    location = /favicon.ico { access_log off; log_not_found off; } 
    location = /robots.txt { access_log off; log_not_found off; } 

    access_log off; 
    error_log /var/log/nginx/example.com-error.log error; 

    error_page 404 /index.php; 

    location ~ \.php$ { 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; 
     fastcgi_index index.php; 
     include fastcgi_params; 
    } 

    location ~ /\.ht { 
     deny all; 
    } 
} 

# FORGE CONFIG (DOT NOT REMOVE!) 
include forge-conf/example.com/after/*; 

example.org

# FORGE CONFIG (DOT NOT REMOVE!) 
include forge-conf/example.org/before/*; 

server { 
    listen 80; 
    listen [::]:80; 
    server_name example.org; 
    root /home/forge/example.com; 

    # FORGE SSL (DO NOT REMOVE!) 
    # ssl_certificate; 
    # ssl_certificate_key; 

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
    ssl_ciphers 'xxxxxxx-$' 
    ssl_prefer_server_ciphers on; 
    ssl_dhparam /etc/nginx/dhparams.pem; 

    add_header X-Frame-Options "SAMEORIGIN"; 
    add_header X-XSS-Protection "1; mode=block"; 
    add_header X-Content-Type-Options "nosniff"; 

    index index.html index.htm index.php; 

    charset utf-8; 

    # FORGE CONFIG (DOT NOT REMOVE!) 
    include forge-conf/example.org/server/*; 

    location/{ 
     try_files $uri $uri/ /index.php?$query_string; 
    } 

    location = /favicon.ico { access_log off; log_not_found off; } 
    location = /robots.txt { access_log off; log_not_found off; } 

    access_log off; 
    error_log /var/log/nginx/example.org-error.log error; 

    error_page 404 /index.php; 

    location ~ \.php$ { 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; 
     fastcgi_index index.php; 
     include fastcgi_params; 
    } 

    location ~ /\.(?!well-known).* { 
     deny all; 
    } 
} 

# FORGE CONFIG (DOT NOT REMOVE!) 
include forge-conf/example.org/after/*; 
+0

여기를 클릭하면 아무 것도 전송되지 않습니다. 그 중 일부는 당신이 보이지 않는 파일을 포함하거나 (당신은'/ *'여러 장소를 포함한다), 또는 PHP 리디렉션 중이다. 'curl -v --location example.org 2> & 1 | pastebinit'라고 뭐라하니? – hanshenrik

+1

첫 번째 가상 호스트는 443에서만 수신하고 두 번째 서버는 80 번 서버에서만 수신 대기합니다. – Narf

+0

'nginx -T'를 실행하여 생성 된 설정을 pastebin.com 링크에 붙여 넣습니다. –

답변

0

나는 당신의 문서 루트에 대한보다 무신론자 이름을 사용하는 것이 좋습니다 것입니다 혼동을 피하기 위해 다음과 같이 사용할 수 있습니다.

/home/forge/site-example 
,210

나중에 예를 들어, 귀하의 흐름을 진단하는 curl를 사용하려고 :

curl -I -L https://google.com 

옵션을 -I은 헤더

그리고 옵션 -L 사이트 http://immortal.run에 대한 예를 들어

리디렉션 따를를 가져옵니다

$ curl -I -L http://immortal.run 
HTTP/1.1 301 Moved Permanently 
Date: Fri, 15 Sep 2017 14:58:43 GMT 
... 

HTTP/1.1 200 OK 
Date: Fri, 15 Sep 2017 14:58:43 GMT 
Content-Type: text/html; charset=utf-8 
... 

알림 :

HTTP/1.1 301 Moved Permanently 

아마도 설정에 문제가있는 것 같습니다.

+0

SSL : 인증서 주체 이름 (example.com)이 대상 호스트 이름 'example.com'과 일치하지 않습니다. –

+0

도메인 당 인증서를 사용해야합니다 – nbari

관련 문제