LoginSignup
1
0

More than 3 years have passed since last update.

nginx sockets通信 ecsデプロイ 「簡単ログインなど挙動がおかしい」

Posted at

sshでサインイン
ec2に入る
docker ps
起動しているappコンテナに入る
docker exec -it [] /bin/bash
ls log/production.logを拝見

HTTP Origin header (https://hoge.com) didn’t match request.base_url(http://hoge.com)
エラーを発見

2017だけど、aws elb使用時のacm発行したssl(HTTPS化)についての的確な解説

結局nginx.confを設定して、port80をlistenする記述をしないと

X-Forwarded-Protoについて
転送されたプロトコル (http または https).を含める

# プロキシ先の指定
# Nginxが受け取ったリクエストをバックエンドのpumaに送信
upstream app {
    # ソケット通信したいのでpuma.sockを指定
  server unix:///app/tmp/sockets/puma.sock;
}

# httpでのアクセスはhttpsにリダイレクトさせる
# serverからhttpに変更
server{
  listen 80;
# ドメインを指定
  server_name sss.red-miso.work;

  access_log /var/log/nginx/access.log;
  error_log  /var/log/nginx/error.log;

# ドキュメントルートの指定
  root /app/public;

  client_max_body_size 100m;
  error_page 404             /404.html;
  error_page 505 502 503 504 /500.html;
  try_files  $uri/index.html $uri @app;
  keepalive_timeout 5;

  location @app {
    proxy_read_timeout 300;
    proxy_connect_timeout 300;
    proxy_redirect off;
    proxy_set_header Host $host;
    #$http_x_forwarded_protoに変更する。
    proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    # 上記server_name で設定した名前で指定
    proxy_pass http://app;
  }
}

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0