Shiny
Shiny
TTCTheo's Typesafe Cult
Created by Shiny on 3/2/2024 in #questions
NextAuth behind nginx https proxy doesn't get session
I have got my app working in development and now wanted to move everything to production. My Database, Next.js and NGINX all run in docker containers. To create a secure connection I configured nginx to handle SSL and redirect everything to https. Now I'm facing the following problem: - When I sign in without the proxy enabled on an http connection everything works fine - When I turn on the proxy: - The "Sign in with discord" button redirects me to the same site again but with ?csrf=true at the end - Clicking it again now redirects to discord correctly - After logging in a session is created in the database but calling session.user returns null I don't get what part fo the authentication fails here. can someone give some advice please My config: - NEXTAUTH_URL='https://production.com' - discord callback: 'https://production.com/api/auth/callback/discord'' - nginx config: upstream nextjs { server 172.17.0.4:3000; } server { # Redirect HTTP requests to HTTPS. listen 80; server_name localhost; root /srv/public; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name localhost; root /srv/public; server_tokens off; ssl_certificate /SSL-Cert/my.crt; ssl_certificate_key /SSL-Cert/my.key; location / { try_files $uri $uri/ @nextjs; } location @nextjs { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Ssl on; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://nextjs; proxy_cookie_path / "/; HTTPOnly; Secure"; } }
3 replies
TTCTheo's Typesafe Cult
Created by Shiny on 3/1/2024 in #questions
create-t3 connect docker server to docker database
I‘ve used the create-t3 framework to set up my project and I‘d like to use it with a postgres database hosted in a docker container. This worked fine I just used the start-db.sh script that gets generated. Now I‘m trying to build a docker image for deploying my app and the process works fine until I try to access the database. I have the postgres container running and started but I can‘t figure out how to connect to it… i just get an Invalid URL error. I‘m using docker compose to inject the environment arguments but the URL with localhost doesnt seem to work. I also tried to use the docker bridge network and used 172.17.0.3 as the IP but that didnt work either. How can i configure this correctly so my docker server can access the docker database
4 replies