-
Notifications
You must be signed in to change notification settings - Fork 0
https 전환
top-chaser edited this page Dec 11, 2023
·
1 revision
- 백엔드에서 cookie 보냈는데 프론트에서 보이지 않았다.
-
cors, cookie 설정 변경 → 실패
-
백엔드도 https 변경 → 성공? 아직 모름
이게 localhost에서는 cookie 가 잘 와리가리 되서 찾아봤더니 같은 도메인이어야 쿠키가 저장된다 함.
일단 백엔드랑 프론트랑 같은 도메인으로 연결해봤음. → 안됨
찾아보니 백엔드는 http인데 프론트는 https였음 그래서 안됨
그래서 백엔드도 https로 바꿨음
근데 하라는 대로 다했지만 또 안됨 ㅜㅜ
2023/11/30 16:12:28 [emerg] 38#38: host not found in upstream "host.docker.internal" in /etc/nginx/conf.d/default.conf:24 nginx: [emerg] host not found in upstream "host.docker.internal" in /etc/nginx/conf.d/default.conf:24
로컬에선 host.docker.internal 도메인으로 호스트에 접근이 가능한데 클라우드 서버에서는 위 에러가 발생했다.
이유를 검색해보니
Mac
또는Windows
에서는 host.docker.internal 도메인으로 접근이 가능하지만Linux
에서 이 도메인을 사용하기 위해서는 아래와 같이 컨테이너를 실행할 때--add-host=host.docker.internal:host-gateway
를 추가해줘야 한다.docker run -it --add-host=host.docker.internal:host-gateway nginx
- nginx 도커 내부의 설정파일
# etc/nginx/conf.d/default.conf server { listen 80; server_name api.gbs-live.site; server_tokens off; location /.well-known/acme-challenge/ { root /var/www/certbot; } location / { return 301 https://$host$request_uri; } } server { listen 443 ssl; server_name api.gbs-live.site; server_tokens off; ssl_certificate /fullchain1.pem; ssl_certificate_key /privkey1.pem; location / { proxy_pass http://host.docker.internal:3000; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
- 서버에 있는 파일들을 도커 내부로 넣기
docker cp ./default.conf [컨테이너 ID]:/etc/nginx/conf.d/default.conf docker cp /etc/letsencrypt/archive/api.gbs-live.site/privkey1.pem [컨테이너 ID]:/ docker cp /etc/letsencrypt/archive/api.gbs-live.site/fullchain1.pem [컨테이너 ID]:/ docker exec [컨테이너 ID] nginx -s reload