2017-08-26 12 views
0

私のサイト(myportal.com)のリバースプロキシとして動作しているnginxを設定する必要があります。 nginxは、squidプロキシ経由で実際のサイトに接続できます。サイトのリバースプロキシとしてnginxを設定する方法

クライアント - > nginx - > Squid Proxy - > Webサーバー。

注:

a。クライアントは、(myportal.comの)Webサーバーとしてnginxを想定しています。

b。 nginxは、実際のサーバ(myportal.com)から、squidプロキシ経由でコンテンツを取得します。

ありがとうTarun。私は、宛先Webサーバが直接到達可能な場合、リバースプロキシとしてnginxを正常に設定しました。しかし、Webに接続している間はイカの後ろにいます。我々は問題に直面している。クライアントがnginxに接続する必要があるので、それが宛先サーバであると仮定します(したがって、プロキシヘッダは送信されません)。 -

次も試しました。

upstream @squid { 
    server localhost:3128; 
} 

server { 
    listen 80; 
    server_name relay.example.com; 

    location/{ 
     proxy_pass http://@squid/$scheme://$host$uri; 

     proxy_set_header Host $host; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header X-Forwarded-Proto $scheme; 
     proxy_set_header Request-URI $request_uri; 

     proxy_redirect off; 
    } 
} 
+0

あなたが試した、何の問題、あなたをしているものを設定私たちを表示します対面している –

+0

質問と更新されたコードを編集し、コマンドに貼り付けないでください。 –

+0

@タルン・ルワンワン..どのような提案? – user1819071

答えて

0

この構成に試してみて、おそらくあなたのアイデアを得るのを助けることができ、リバースプロキシとキャッシングとしてnginxのを使用している:

... 
    proxy_buffering on; 
    proxy_cache_path /home/cache levels=1:2 keys_zone=myportal:256m max_size=5g inactive=24h use_temp_path=off; 
    proxy_buffer_size 8k; 
    proxy_buffers  8 24k; 

    server { 
     listen  80; 
     server_name _; 

     location/{ 
      proxy_cache myportal; 
      proxy_cache_use_stale updating error timeout invalid_header http_500 http_502 http_503 http_504; 
      proxy_cache_revalidate on; 
      proxy_cache_min_uses 1; 
      proxy_cache_lock on; 
      proxy_cache_valid 200 301 304 2d; 
      proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie; 

      proxy_redirect off; 
      proxy_set_header X-Real-IP $remote_addr; 
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
      proxy_set_header X-Forwarded-Proto $scheme; 
      proxy_set_header Host myportal.tld; 
      proxy_set_header Connection ""; 
      proxy_http_version 1.1; 
      proxy_pass https://myportal.tld/; 
     } 
    } 
    ... 
+0

ありがとう@nbari。宛先Webサーバが直接(nginxから)到達可能であるが、それがイカの後ろにある場合、リバースプロキシ設定は正常に動作しています。私たちは問題 – user1819071

+0

に直面しています。私は 'proxy_set_header Host myportal.tld;をチェックする必要があると思っています。 – nbari

関連する問題