Welcome! Log In Create A New Profile

Advanced

Subdomain configuration with Letsencryt wildcard TLS

Posted by Hyrozen 
Subdomain configuration with Letsencryt wildcard TLS
August 20, 2019 05:46AM
What I want to do ?

I have two application on local ports and I want to access them like that :
- maindomain.com -> node.js app
- sub.maindomain.com -> .net core app


My DNS config
- maindomain.com (A Record) 11.111.11.111
- sub.maindomain.com (A Record) 11.111.11.111


Nginx config

> /etc/nginx/sites-enabled/maindomain.com (linked from ./sites-available/)

upstream node_app{
# node.js running
server 127.0.0.1:8000;
}

server{
listen 80;
server_name www.maindomain.com maindomain.com;
#Redirige toutes les requĂȘtes http vers https
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/maindomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/maindomain.com/privkey.pem;

location / {
include proxy_params;
proxy_pass http://node_app;
}
}


> /etc/nginx/sites-enabled/sub.maindomain.com (linked from /sites-available/)

upstream core_api{
# Asp.net core API running in background
server 127.0.0.1:5000;
}

server{
listen 80;
server_name www.sub.maindomain.com sub.maindomain.com;
return 301 https://$host$request_uri;
}

server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/maindomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/maindomain.com/privkey.pem;

location / {
include proxy_params;
proxy_pass http://core_api;
}
}


Result :

After that, I have restarted my nginx service.
Requests on sub.maindomain.com just redirect on maindomain.com.

What did I missed ?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 152
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready