Welcome! Log In Create A New Profile

Advanced

Serve same website under two URLs / domains with certbot

June 04, 2021 11:23PM
Hello All,

Using nginx/1.14.2 on Linux rpi3 5.10.17-v7+. Historically I ended up with two domains. I started with a dyndns 'domain' (is that actually correct to call it domain?) to operate my homemade RPI weather station. Later I got a domain from 'hover.com' to run my astronomy hobby webpage. Both pages are on the same RPI on the same directory branch and actually the domains manes are interchangeable. You can see my weather station at:

http://drgert.dyndns.ws:8000/rpi/rpi.html
http://www.skywatcher.space/rpi/rpi_wetter/rpi_wetter.php

So far I had one default config:
ls -l /etc/nginx/sites-enabled
lrwxrwxrwx 1 root root 26 Jun 4 20:12 default -> ../sites-available/default

Content:
server {
listen 80 default_server;
listen 8000; # Alternate http port
root /media/usbstick/nginx/www;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm;
server_name localhost;
location / {
try_files $uri $uri/ =404;
}

# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
}

Now I want to use certbot for https.
But that requires certificates unique for each domain. (I think)

So I tried deleting the default file and have two conf files in conf.d for each domain.

vi /etc/nginx/conf.d/www.skywatcher.space.conf
server {
listen 80 default_server;
listen [::]:80 default_server;
root /media/usbstick/nginx/www;
server_name skywatcher.space www.skywatcher.space;
}

vi /etc/nginx/conf.d/www.drgert.dyndns.ws.conf
server {
listen 80 default_server;
listen 8000; # Alternate http port
root /media/usbstick/nginx/www;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm;
server_name drgert.dyndns.ws www.drgert.dyndns.ws;
location / {
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
}

But then each such file had 'default_server' keyword in it and it failed to work.
Also I don't know if its OK that both try to listen on port 80.

So how do I do this right?

Both domains pointing to the same html files root and both should receive https certificates. :-)

Cheers,
Gert
Subject Author Posted

Serve same website under two URLs / domains with certbot

forumacct June 04, 2021 11:23PM

Re: Serve same website under two URLs / domains with certbot

Francis Daly June 05, 2021 03:22PM

Re: Serve same website under two URLs / domains with certbot

forumacct June 05, 2021 05:06PM

Re: Serve same website under two URLs / domains with certbot

Francis Daly June 09, 2021 07:18PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 63
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready