Nginx+nextjs
Unanswered
Valentine ant posted this in #help-forum
Valentine antOP
Hi, I need help about building Nextjs with nginx webserver, I need to crate reverse proxy for redirect to port 3000 when domain is requested?
10 Replies
@Valentine ant Hi, I need help about building Nextjs with nginx webserver, I need to crate reverse proxy for redirect to port 3000 when domain is requested?
server {
listen 443;
server_name whatever.youwant;
ssl_certificate /etc/nginx/cert.crt; #MAKE SURE YOUR KEYS EXIST IN THE RIGHT PLACE
ssl_certificate_key /etc/nginx/cert.key;
ssl on;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:3000;
}
}this is the config that I use personally
if you don't have ssl cert ready with you, change port to 80 and remove all ssl config
then run certbot
certbot will already take care of ssl
Valentine antOP
O thanks, I have already cloudflare ssl in nginx
So the security Header can be set on the enabled site file or in Nextjs too?
I see proxy pass is in http,can be sett at https?
@Valentine ant I see proxy pass is in http,can be sett at https?
Beveren
Ur setting proxy to ur next.js app, so it depends if it supports https or not
Valentine antOP
A okay