Nginx: HTTPS를 통해 이미지가 제공되지 않음

Nginx: HTTPS를 통해 이미지가 제공되지 않음

admin/내 사이트에 HTTPS에 포함하려는 하위 디렉터리가 있으므로 다음을 기반으로 다음 구성을 시도했습니다.이것:

server {
    listen 80;

    server_name blob.tld;
    root /srv/www/blob;
    index index.php index.html index.htm;

    location /blog/admin/* {
        return 301 https://$server_name$request_uri;
    }

    location / {
        try_files $uri $uri/ $uri/index.php /index.html;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}

server {
    listen 443 ssl;
    server_name blob.tld;

    root /srv/www/blob/;
    index index.php index.html index.htm;

    ssl_certificate /srv/www/blob.tld.pem;
    ssl_certificate_key /srv/www/blob.tld.key;

    ssl_session_timeout 5m;

    ssl_protocols SSLv3 TLSv1;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
    ssl_prefer_server_ciphers on;

    location /blog/admin {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        try_files $uri $uri/index.php /index.html;
    }

    location / {
        return 301 http://$server_name$request_uri;
    }
}

admin/style/하지만 이미지가 제공되지 않습니다.

로그 파일을 확인해 보니 다음과 같습니다.

/var/log/nginx/access.log:
127.0.0.1 - - [25/Apr/2014:15:06:27 +0200] "GET /blog/admin/style/lock.png HTTP/1.1" 403 46 "-" "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit (KHTML, like Gecko) Chrome/32.0"

/var/log/nginx/error.log:
2014/04/25 15:06:27 [error] 23629#0: *404 FastCGI sent in stderr: "Access to the script '/srv/www/blob/blog/admin/style/lock.png' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 127.0.0.1, server: blob.tld, request: "GET /blog/admin/style/lock.png HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000"

error.log 파일을 보면 문제는 HTTPS 서버의 첫 번째 위치 지시문에서 발생한 것 같습니다(HTTP와의 차이점은 입니다 ~ \.php$).그래서 정확한 대칭을 만들려고 노력해요( \.php$다른 지시문 location내의 지시문 포함):

server {
    listen 443 ssl;
    [...]

    location /blog/admin/* {
        try_files $uri $uri/ $uri/index.php /index.html;
    }

    location / {
        return 301 http://$server_name$request_uri;
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include fastcgi_params;
    }
}

하지만... HTTPS가 전혀 없습니다.

이미지를 HTTP로 제공하는 방법이 아직 남아 있지만 약간 실망스럽습니다.

location  /blog/admin/style {
    return 301 http://$server_name$request_uri;
}

나는 nginx 1.1.19와 php 5.3.10과 php-fpm을 가지고 있습니다.

답변1

https 부분을 보내는 이유는 무엇입니까?모든 것/blog/admin 아래의 FastCGI로 이동하시겠습니까? http 부분과 같이 *.php에 대해 특별히 규칙을 만들어 보는 것은 어떨까요?

즉, http 아래에는 다음이 있습니다.

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi_params;
}

그러나 https 아래에는 다음이 있습니다.

location /blog/admin {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    include fastcgi_params;
    try_files $uri $uri/index.php /index.html;
}

내 생각엔 네가 바뀌면/블로그/관리자도착하다~/블로그/관리자/.*\.php$당신의 문제는 해결될 것입니다...

관련 정보