nginx


ubuntu整理環境でよく使われるnginxコマンドとnginx.conf設定
  • nignx http prox module説明
  • リバースエージェント使用時のクッキーの使い方
  • 禹奮闘でよく使われるnginx command line
  • nignx logs確認法
  • 1.nginx http proxy module説明
    リンク:http://nginx.org/en/docs/http/ngx_http_proxy_module.html
    2.リバースエージェントを使用する場合のクッキーの使用方法
    server {
      ...
      location / {
        # 요기부터
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass <url>
        # 요기까지 추가하면 됨
        proxy_redirect off;
     }
     ...
    
    ここのポイントはusing secure sessions behind an http proxyこのリンクがよく説明されています.
    コアはproxy_set_header X-Forwarded-Proto $schemeWhy does this matter? Isn’t everything is served via https anyway?
    Of course, but everything is also served via an ELB which proxies to our nginx cluster, which in turn proxies to our apps servers via internal http connections. The fix is trivial as it’s easy to set/modify headers in nginx, making the header validation in Connect quite pointless – proxy_set_header x-forwarded-proto https;.
    In completely unrelated news, sessions on GoSquared now use secure + httponly cookies!
    PS. remember to add proxy_set_header Host $host; too if you need the host header to be forwarded too, it appears to get lost otherwise.
    内部エージェントはhttpconnectionです.したがって、cookie secureを実装するには、proxy set headerx-predired-proto httpsを設定する必要があります.また、host headerを渡すにはproxy set headerhost$hostを設定する必要があります.
    3.右奮闘でよく使われるnginx command line
  • nginx開始:sudo systemctl start nginx
  • nginx状態検査:sudo systemctl status nginx
  • nginx再起動:sudo systemctl restart nginx
  • 4.nginx logs確認方法
    エラーログはnginxプロファイルに表示され、ログがどこに蓄積されているかが表示されます.
    コメントリンク
  • using secure sessions behind an http proxy: https://www.gosquared.com/blog/secure-sessions-http-proxy
  • リバースエージェント使用時クッキー.secure: https://github.com/dotansimha/graphql-yoga/issues/472