2017-08-30 6 views
0

私は次のように私の設定があるnginxのしっかりとエラー時に逆プロキシ

を使用してセットアップにContentful CDNのキャッシュリバースプロキシをしようとしています:

のコースspaceIdとaccessTokenValueが適切なものである
http { 
    proxy_cache_path /my/cache levels=1:2 keys_zone=STATIC:10m  inactive=24h max_size=1g; 

    log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 
         '$status $body_bytes_sent "$http_referer" ' 
         '"$http_user_agent" "$http_x_forwarded_for"'; 

    access_log /var/log/nginx/access.log main; 

    sendfile   on; 
    tcp_nopush   on; 
    tcp_nodelay   on; 
    keepalive_timeout 65; 
    types_hash_max_size 2048; 

    include    /etc/nginx/mime.types; 
    default_type  application/octet-stream; 

    # Load modular configuration files from the /etc/nginx/conf.d directory. 
    # See http://nginx.org/en/docs/ngx_core_module.html#include 
    # for more information. 
    include /etc/nginx/conf.d/*.conf; 


     server { 
      listen 443 ssl; 
      server_name my.domain.com; 
      server_tokens off; 
      root /my/www/client; 
      index index.html; 
      try_files $uri $uri/ /index.html; 

      auth_basic "Private Property"; 
      auth_basic_user_file /pass/.htpasswd; 


      ssl_certificate /my/ssl/cert.crt; 
      ssl_certificate_key /my/ssl/key.key; 
       ssl_dhparam /etc/ssl/certs/LS-dhparam.pem; 
       ssl_protocols  TLSv1 TLSv1.1 TLSv1.2; 
       ssl_prefer_server_ciphers on; 
       ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECD$ 

      location /spaces { 
       index index.html index.htm; 
       charset utf-8; 
       proxy_pass http://cdn.contentful.com/spaces/spaceId/entries?access_token=accessTokenValue; 
       proxy_ignore_headers Cache-Control Expires; 
       proxy_cache STATIC; 
       proxy_cache_valid 200 10m; 
       proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504; 
       proxy_redirect off; 
       proxy_set_header Host $host; 
       proxy_set_header X-Forwarded-Host $host; 
       proxy_set_header X-Forwarded-Server $host; 
       proxy_set_header X-Real-IP $remote_addr; 
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_For; 
       proxy_set_header Connection ""; 
       proxy_http_version 1.1; 

       proxy_connect_timeout 90s; 
       proxy_send_timeout 90s; 
       proxy_read_timeout 90s; 
       proxy_buffer_size 4k; 
       proxy_buffers 4 32k; 
       proxy_busy_buffers_size 64k; 
       proxy_temp_file_write_size 64k; 
       send_timeout 90s; 

      } 
     } 
} 

私は、このエラーを返しhttps://my.domain.com/spaces/&content_type=myContent&locale=en

上の要求トリガ:しっかりエラー:不明なドメイン:私を。 domain.com。このドメインがサービスに追加されたことを確認してください。

私は完全なURLビーイングを使用しようとすると、それは動作します:http://cdn.contentful.com/spaces/spaceId/entries?access_token=accessTokenValue&content_type=myContent&locale=en

は私のnginxの設定に何か問題があるのか​​contentfulの側から何かはありますか?

+0

元のリクエストからプロキシのパスに引数を渡そうとしていますか?絶対URLの 'https:// my.domain.com/spaces /'もまたそれ以降の追加事項がありますか? –

+0

私はyesに引数を渡したいと思います。 (例では、2つのURLを見ることができます。最初のURLを2番目のURLに変換します) – mangusbrother

+0

次に、proxy_passを 'proxy_pass http://cdn.contentful.com/spaces/spaceId/entries?access_token=accessTokenValue&$に変更します。 query_string';それが助けてくれたら、 –

答えて

1

あなたは仕事に、このために

proxy_set_header Host $host; 

を削除する必要があります。 proxy_pass http://cdn.contentful.com/spaces/spaceId/entries?access_toke‌​n=accessTokenValue&$‌​query_stringにproxy_passすると、ホスト名がcdn.contentful.comのままで、変更されないようにしたいから

関連する問題