문제

Jekyll과 함께 Github에서 호스팅하는 블로그가 있습니다. 저기있어 : http://blog.superfeedr.com

이상적으로는, 나는 그것이 있고 싶다 http://superfeedr.com/blog/ 우리는 약간의 ajax를 추가해야하며 "동일한 원산지 정책"문제를 피해야하기 때문입니다.

우리는 "메인"웹 서버에서 nginx를 사용하고 다음과 같은 설정이 있습니다.

location /blog/ {

proxy_pass http://blog.superfeedr.com/;
    proxy_redirect     off;
    proxy_max_temp_file_size 0;

    client_max_body_size       10m;
    client_body_buffer_size    128k;

    proxy_connect_timeout      90;
    proxy_send_timeout         90;
    proxy_read_timeout         90;

    proxy_buffer_size          4k;
    proxy_buffers              4 32k;
    proxy_busy_buffers_size    64k;
    proxy_temp_file_write_size 64k;
}

불행히도, 당신이 가면 볼 수 있듯이 http://superfeedr.com/blog/ 이것은 분명히 작동하지 않습니다. 이상하게도, 우리는 Github의 홈페이지로 리디렉션되었습니다.

추신 : 분명히, 우리는 메인 서버에서 블로그를 호스팅 할 수 있지만 목표는 사이트가 다운되면 온라인 상태를 거의 보장 할 수 있도록 다른 호스트에서이를 호스팅하는 것입니다.

도움이 되었습니까?

해결책

먼저, Nginx는 호스트 헤더를 블로그로 보내지 않습니다 .superfeedr.com. 이렇게하면 필요한 모든 헤더를 보냅니다.

proxy_set_header   Host                    blog.superfeedr.com;
proxy_set_header   X-Host                 blog.superfeedr.com;
proxy_set_header   X-Real-IP             $remote_addr;
proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

둘째, 일부 URL 재 작성이 필요합니다. 이상한 이유는 이것이 사용중인 Nginx 버전에 달려 있습니다. 어쨌든, 0.6.x (0.6.32)의 경우 이것이 효과가 있어야합니다.

    location /blog {
                rewrite  ^/blog(.*)$ /$1 last;
                error_page 402 = @blog;
                return 402;
    }
    location @blog {
        proxy_pass http://blog.superfeedr.com;

        # the rest of proxying parameters should be here

         proxy_set_header   Host                    blog.superfeedr.com;
         proxy_set_header   X-Host                 blog.superfeedr.com;
         proxy_set_header   X-Real-IP $remote_addr;
         proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    }

또한 블로그가 지칭하는 모든 경로 (CSS, 이미지 등)도 포함해야합니다.

location /css {
    error_page 402 = @blog;
    return 402;
}

0.7.59 :

        location /blog {
                set $blog 1;
                rewrite  ^/blog(.*)$ /$1 last;
        }
        location /css {
                set $blog 1;
                error_page 402 = @blog;
                return 402;
        }
        location / {
                if ($blog) {
                        error_page 402 = @blog;
                        return 402;
                }
                # here is where default settings for / should be
                root /usr/local/www/nginx/;
        }
        location @blog {
                proxy_pass http://blog.superfeedr.com;

                # the rest of proxying parameters should be here

                proxy_set_header   Host                   blog.superfeedr.com;
                proxy_set_header   X-Host                 blog.superfeedr.com;
                proxy_set_header   X-Real-IP $remote_addr;
                proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        }

다른 팁

이 작업을 수행하는 또 다른 방법 (그러나 Nginx를 포함하지 않으면)은 DNS 지침에있을 수 있습니다. 대부분의 DNS 서비스가 URL 포워드 서비스를 제공한다고 생각합니다.

예를 들어, hover.com에서 먼저 추가하십시오 blog ~와 함께 A 지침 64.99.80.30 DNS 탭에서 다음 전방 탭에서 추가 blog 를 향해서 http://superfeedr.com/blog/

dnsimple.com에서는 더 간단합니다 blog URL 전달할 기록 http://superfeedr.com/blog/

이 전진은 또한 효과가 있다고 생각합니다 https:// URL을 입력하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top