I've successfully set-up an SSL-certificate through the certbot with DNS-plugin. This works great and I have issued a certificate for example.com and *.example.com:
certbot certificates output:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Found the following certs:
Certificate Name: example.com
Domains: example.com *.example.com
Expiry Date: 2022-02-28 11:09:56+00:00 (VALID: 89 days)
Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem
Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
So far so good, all domains seem to be secured correctly:
example.com = OK
test.example.com = OK
However, the issue starts for the domain test1.test.example.com. The browser keeps complaining about the fact that the domain is not secured..! I've already re-issued the SSL-certificate. This succeeds, but still the domain is marked as insecure.
Important to note, if I modify the Apache config for the domain to not redirect http (insecure) traffic to https (secure) traffic, I can access the site. This validates my apache set-up, which in fact is only 1 config file, allowing:
ServerName example.com
ServerAlias *.example.com
EDIT: Perhaps this helps. Safari tells me that the name of the certificate example.com does not match the input? Firefox returns SSL_ERROR_BAD_CERT_DOMAIN. So, I tried to update the domain to also allow *.*.example.com, but that's not allowed by certbot as it returns: Cannot issue for '*.*.example.com': Domain name has more than one wildcard
EDIT 2: The DNS-plugin generated a json-file that contains the auth-information to validate the domains. This file contains an entry fulldomain and subdomain, but the issue is with a two level 'sub-sub' domain? Perhaps this is the issue? How can I fix this, as the certbot plugin does not allow multi wildcard domains?
I've figured it out, it's not allowed to use a wildcard character before the first dot in the domain-name (at least not with the DNS-plugin I use).
Therefore, I successfully got it working adding the domain like: -d *.test.example.com
After issuing and overwriting the old certificate with the new one, this worked perfectly as expected.
example.com = OK
test.example.com = OK
test1.test.example.com = OK
Related
In documentation basics, we find the following examples for configuration of the hosts YAML element:
Serving one domain:
hosts: [example.org]
Serving three domains:
hosts:
- example.net
- example.com
- jabber.somesite.org
(The above are of course just two different ways of writing a YAML "list", once using the bracket notation, once using the indent-with-hypen notation).
A bit later, we see:
## This ejabberd server has three vhosts:
hosts:
- one.example.org
- two.example.org
- three.example.org
This is confusing.
As I understand, an XMPP domain (e.g. example.com) can be serviced by several servers or hosts (e.g. one.example.com, two.example.com, three.example.com).
The configuration seems to commingle XMPP domain and server.
Is the XMPP domain deduced from the servername? For example, if I enter one.example.org, is the XMPP domain example.org - or is it one.example.org?
If I just give the domain name under hosts, do I have to map the domain name to an actual IP endpoint in DNS?
Additionally, an SSL certificate will be requested via ACME
Will this be a certificate for the XMPP domain (example.com) or for the server (one.example.com) or will it be a wildcard certificate?
Will the ACME service (of Letsencrypt, say) give me a certificate for example.org if I already have a certificate for the webserver of example.org?
You can even have:
hosts:
- example.net
- example.com
- jabber.somesite.org
- one.example.org
- two.example.org
- three.example.org
- 11.22.33.44
This sets 7 different XMPP vhosts, each one with their specific accounts, MUC service, PubSub service...
Clients can authenticate to accounts like jon#example.net, tim#two.example.org, bot7#11.22.33.44, ...
It is your duty, as system administrator, to setup DNS so the XMPP clients know the IP address where ejabberd is listening for them. Except for the 11.22.33.44 IP address, which obviously the clients already know where to connect to.
Notice that you can have ejabberd serving one.example.org, and same or different XMPP server, in same or different machine, serving eleven.example.org
I'm trying to setup traefik v2 on a development server we have.
The setup:
Docker serving dozens of nginx containers acting as a frontend for different projects. Every nginx container has a unique domain linked to it. Nginx is running on port 80. Every project has a separate docker-compose (traefik also has a separate docker-compose).
What I'm trying to accomplish:
Proxy all of the containers to traefik and add new ones on the go (new services are stopped/started all the time). Make traefik automatically redirect to HTTPS and contact the appropriate nginx container based on the hostname in order to serve the website.
Question: Is this even possible to do? I've been trying to figure it out for the past day or so but I can't get everything to work. Either the redirect doesn't work or if it does it returns 404.
Managed to find a guide that covers this:
https://chriswiegman.com/2019/10/serving-your-docker-apps-with-https-and-traefik-2/
To extend what the guide pointed to, the magic sauce is in LABELS. It can be broken down to this:
# Setup HTTP
# tells traefik that cany HTTP connection needs to be re-directed to HTTPS
- "traefik.http.middlewares.mysite-https.redirectscheme.scheme=https"
# 'web' (or any name) can be defined my traefik entrypoints. Web is port 80.
- "traefik.http.routers.mysite-http.entrypoints=web"
# tells to route incoming connections to 'mysitesdomain.com' to this service
- "traefik.http.routers.mysite-http.rule=Host(`mysitesdomain.com`)"
# Maps the above 'middleware' called 'mysite-https'
- "traefik.http.routers.mysite-http.middlewares=mysite-https#docker"
# Setup HTTPS
- "traefik.http.routers.mysite.entrypoints=web-secure"
- "traefik.http.routers.mysite.rule=Host(`mysitesdomain.com`)"
- "traefik.http.routers.mysite.tls=true"
- "traefik.http.routers.mysite.tls.certresolver=default"
What seems to be missing the loadbalancer definition.
- "traefik.http.services.replica_service.loadbalancer.server.port=80" # "80" is the container's incoming port.
I'm trying to setup a route do a basic 301 redirect with the added benefit of supporting both HTTP and HTTPS requests. Expected results would be that requests to http://subdom.domain.org or https://subdom.domain.org would receive a 301 and be forwarded to https://othersub.domain.org/route. Actual results is that https://subdom.domain.org 301's as expected, but http://subdom.domain.org 404's. With the config, you can see I've tried doing both an elevate to HTTPS with the hopes that the rule might be caught there, but with the way the middleware is configured, I would expect it would work in either scenario.
Here's my current config:
http:
routers:
subdom.domain.org:
entryPoints:
- web
- web-secure
middlewares:
- https-redirect # I've tried with this on and off
- sudbdom-redirect
service: dummy
rule: Host(`subdom.domain.org`)
tls:
certResolver: letsEncryptResolver
middlewares:
https-redirect:
redirectScheme:
scheme: https
subdom-redirect:
redirectRegex:
regex: ".*"
replacement: "https://othersub.domain.org/route"
permanent: true
services:
dummy:
loadBalancer:
servers:
- url: localhost
I was originally having trouble matching specific regex patterns for the redirect, but in realizing I didn't really need to scope the pattern at all given that I'm applying it per route, a wildcard match seems to work quite well there. Any thoughts or suggestions are appreciated. Thanks!
You should try to make 2 different router one for web entry point where you can perform redirection and 2rd one for redirectRegex where you can redirect your application to different url.
Following TLS section from official documentation:
When a TLS section is specified, it instructs Traefik that the current router is dedicated to HTTPS requests only (and that the router should ignore HTTP (non TLS) requests).
Solutions:
1. Define separate routers (for http and https), but it noisy for multiple services.
If you need to define the same route for both HTTP and HTTPS requests, you will need to define two different routers: one with the tls section, one without.
Example from documentation
2. Disable TLS for router
traefik.http.routers.YOUR-SERVICE.tls=false
Example:
services:
mailhog:
image: mailhog/mailhog
networks:
- traefik-public
deploy:
placement:
constraints:
- node.role != manager
labels:
- "traefik.enable=true"
- "traefik.http.routers.mailhog.rule=Host(`mailhog.somehost.ru`)"
- "traefik.http.routers.mailhog.service=mailhog"
- "traefik.http.routers.mailhog.entrypoints=web,websecure"
# Should be false
- "traefik.http.routers.mailhog.tls=false"
- "traefik.http.middlewares.redirectos.redirectscheme.scheme=https"
- "traefik.http.routers.mailhog.middlewares=redirectos"
- "traefik.http.services.mailhog.loadbalancer.server.port=8025"
- "traefik.tags=traefik-public"
- "traefik.docker.network=traefik-public"
I am trying to set up a website with HTTPS on a Linode server. It's working on HTTP but not on HTTPS.
I tried to use Certbot to configure my domain for HTTPS.
root#mailer9:/etc/apache2/sites-enabled# sudo certbot --apache
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: mailer9.com
2: www.mailer9.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel):
Attempting to parse the version 0.29.1 renewal configuration file found at /etc/letsencrypt/renewal/mailer9.com.conf with version 0.28.0 of Certbot. This might not work.
Cert not yet due for renewal
You have an existing certificate that has exactly the same domains or certificate name you requested and isn't close to expiry.
(ref: /etc/letsencrypt/renewal/mailer9.com.conf)
What would you like to do?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Attempt to reinstall this existing certificate
2: Renew & replace the cert (limit ~5 per 7 days)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for mailer9.com
http-01 challenge for www.mailer9.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/mailer9.com-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/mailer9.com-le-ssl.conf
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Your existing certificate has been successfully renewed, and the new certificate
has been installed.
The new certificate covers the following domains: https://mailer9.com and
https://www.mailer9.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=mailer9.com
https://www.ssllabs.com/ssltest/analyze.html?d=www.mailer9.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/mailer9.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/mailer9.com/privkey.pem
Your cert will expire on 2019-04-02. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
root#mailer9:/etc/apache2/sites-enabled#
It says that thing should be working fine but it's not working in HTTPS mode.
I see two VH files in sites-enabled directory.
root#mailer9:/etc/apache2/sites-enabled# cat mailer9.com.conf
# domain: mailer9.com
# public: /var/www/html/mailer9.com/public_html/
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin xxx#yy.com
ServerName mailer9.com
ServerAlias www.mailer9.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/mailer9.com/public_html
# Log file locations
LogLevel warn
ErrorLog /var/www/html/mailer9.com/log/error.log
CustomLog /var/www/html/mailer9.com/log/access.log combined
#RewriteEngine on
#RewriteCond %{SERVER_NAME} =mailer9.com [OR]
#RewriteCond %{SERVER_NAME} =www.mailer9.com
#RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Another one for HTTPS, auto-generated by Certbot.
root#mailer9:/etc/apache2/sites-enabled# cat mailer9.com-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin xxx#yy.com
ServerName mailer9.com
ServerAlias www.mailer9.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/html/mailer9.com/public_html
# Log file locations
LogLevel warn
ErrorLog /var/www/html/mailer9.com/log/error.log
CustomLog /var/www/html/mailer9.com/log/access.log combined
SSLEngine on
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/mailer9.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mailer9.com/privkey.pem
</VirtualHost>
</IfModule>
root#mailer9:/etc/apache2/sites-enabled#
However, if I visit http://mailer9.com/ then it works fine. But if I go to https://mailer9.com/ the page doesn't load. I am clueless about how to solve it, everything looks fine to me.
Apache modules command apachectl -M shows ssl_module is loaded.
It was caused because of ufw firewall. I added port 443 and it fixed it.
sudo ufw allow 443/tcp
I have a domain balanced in 2 IPs:
A - domain.com - 1.1.1.1
A - domain.com - 2.2.2.2
but I want to convert the IPs on CNAMEs:
So, i've created 2 "A" entries:
A - master - 1.1.1.1
A - slave - 2.2.2.2
and I want to create 2 CNAMEs from root domain to another 2 servers in order to get working as load balancer:
CNAME - domain.com - master.domain.com
CNAME - domain.com - slave.domain.com
but Cloudflare don't permitt create 2 same CNAMEs although the domain target be different
How can I create an "domain.com" entry to get targeted to the 2 another load balance servers by using CNAMEs?
I've created 2 "A" records:
A - balanced - 1.1.1.1
A - balanced - 2.2.2.2
and then link CNAME to "A"
CNAME - www - balanced.domain.com