By zartom
I’ve configured two nodejs apps and launched them using pm2.
I’ve configured nginx for domain.link and everything is working fine.
server {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name domain.link www.domain.link;
location / {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain.link/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.link/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.domain.link) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = domain.link) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name domain.link www.domain.link;
return 404; # managed by Certbot
}
The second app I’ve configured very similar:
server {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name auth.domain.link www.auth.domain.link;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/auth.domain.link/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/auth.domain.link/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.auth.domain.link) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = auth.domain.link) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name auth.domain.link www.auth.domain.link;
return 404; # managed by Certbot
}
Unfortunately, when I go to auth.domain.link, I’ve got an error ERR_TOO_MANY_REDIRECTS. What should I change in my configuration?
Thanks in advance
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi there,
Are you using Auth0 for your auth subdomain? If so you need to define app.set("trust proxy", 1); in your application.
Let me know how it goes! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.