2012-03-20 7 views
2

私はec2でリバースプロキシを設定して、nginxを使用してカスタムドメインを介してappengineアプリに安全にアクセスしようとしています。ページがユーザーサービスを必要とする場合を除いて、正常に動作しているようです。 Googleアカウントのログインにリダイレクトされた後、カスタムドメインの代わりにappspotドメインに移動します。私はappengineがテストでsslを持っていることを知っていますが、私は今使用できる解決策が欲しいです。これを克服することは可能ですか、自分のユーザーを作成する必要がありますか?AppEngineでSSLのリバースプロキシを使用する方法とUsersサービスを使用する方法

server { 
    listen 443; 
    server_name <custom-domain>; 

    keepalive_timeout 70; 

    ssl on; 
    ssl_certificate  /etc/nginx/cert/server.crt; 
    ssl_certificate_key /etc/nginx/cert/server.key; 
    ssl_session_timeout 30m; 

    location/{ 
     proxy_redirect off; 
     proxy_pass  https://<appid>.appspot.com; 
     proxy_set_header Host <appid>.appspot.com; 

     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 

     proxy_intercept_errors off; 
    } 
} 

マイドメインはEC2へのCNAMEのポインティングがあります

以下は、私の構成です。

===

回避策が見つかりました。それでももっと簡単なことを望んでおり、フィードバックを感謝します。続き

1) Client hits https: //mydomain.com/blah which goes through EC2 proxy https://appid.appspot.com/blah 
2) The client is redirected to the google login page, with continue set as /aa?continue=/blah 
3) Client logs into Google Accounts and is then redirected to https: //appid.appspot.com/aa?continue=/blah 
4) Client hits https: //appid.appspot.com/aa which serves a redirect to https://mydomain.com/sc?c=ACSID&continue=/blah where ACSID is the Google account session cookie read by the handler for /aa. 
5) Client hits https: //mydomain.com/sc?c=ACSID&continue=/blah which sets the ACSID session cookie for the domain mydomain.com and redirects to https: //mydomain.com/blah based on a continue parameter in aa passed to sc 

が私の(いくつかのトリッキーなURLはエスケープと)ハンドラで制限された後のweb.xml

/ is publicly accessible 
/aa is publicly accessible 
/sc is publicly accessible 
/* is restricted to logged in users 

次のとおりです。この後

/ --> if not logged in, redirect to login page continue=/aa 
/aa --> if not logged in, redirect to login page continue=/aa 
/sc --> if not logged in, redirect to login page continue=/aa 
/* --> if not logged in, redirect to login page continue=/aa?continue=* 

、ユーザーサービスがいるようですSSLを使用しているプロキシ経由でも正常に動作します。 ACSID Cookieはmydomain.comにあり、プロキシを介してappengineに送信されます。

appspotドメインはまだ技術に詳しいユーザーには表示されますが、これは私の主な関心事ではありません。私の目標はhttpsを超えてサービスを提供し、私のカスタムドメインをURLバーに保持し、私のカスタムドメインを使用してSSLなしでサービスするユーザーデータをより安全にすることです。トランザクション全体がhttpsを超えているため、SSLを使用せずにmydomain.comを使用するよりもセッションCookieを公開するとは限りません。とにかくこのスキームがなくても、他のクロスサイト攻撃は機能します。

なぜmydomain.com/_ah/conflogin?state=blahが失敗し、この回避策が必要なのかまだ分かりません。

答えて

0

あなたの回避策は私の問題を解決しました - ありがとう!

これは、私が思いついたコードです。他の誰かが同じ状況に陥っているためです。これはいくつかのサイト固有のものが引き出されているため、動作させるために微調整が必​​要な場合があります。 httpsを使用しているため、CookieはSACSIDです。私はそれがhttpのACSIDだろうと思う。ここ

class CompleteLoginHandler(BaseHandler): 
    def get(self): 
     redirect_to=self.request.get('next', '/') 
     if not redirect_to.startswith('/'): # don't allow redirects to another domain 
      redirect_to = '/' 
     session_id = self.request.get('SACSID', None) 
     if session_id: 
      self.response.set_cookie('SACSID', session_id) 
     return self.redirect(redirect_to) 

class PostLoginRedirectHandler(BaseHandler): 
    def get(self): 
     domain = self.request.headers.get('X-Forwarded-Host', None) 
     if domain is None: 
      # we are on the bare url; need to transfer the user -- and cookie 
      sacsid = self.request.cookies.get('SACSID') 
      next_url = config['domain'] + self.uri_for('complete_login', next=self.uri_for(route_name), SACSID=sacsid) 
      return self.redirect(next_url) 
     else: 
      return self.redirect('/') 

は、PostLoginRedirectHandlerステップを扱っている(4)、及びCompleteLoginHandler(5)tarun2000の説明のステップを扱っている

関連する問題