You are not logged in.

#1 2018-10-18 14:44:05

markJT
Member
Registered: 2018-10-18
Posts: 13

[SOLVED] Apache rewrite self-hosted DynDNS to registered domain https

Hi all,

I've been struggling with this for a while and google/duckduckgo hasn't yielded an answer, nor the search function here.

I would like to: self-host with apache (virtual hosts) and retain HTTPS on a registered domain pointing to a DynDNS.

I don't have a fixed IP so I have a dynamicDNS (via nsupdate). I then have a registered domain that I am pointing to my DynamicDNS. I have SSL certificates for my dynamicDNS URL from sslforfree.com. These certificates include mydomain.xyz. What I can't seem to work out is how (or whether) it's possible to retain my registered domain in the URL bar of a browser and have this showing HTTPS as well.

My current setup:

1. Registered domain via gen.xyz using record type URL Redirect pointing to https://mydomain.nsupdate.info

Other record types can be: A (Address), AAAA (Address), CNAME (Alias), URL Frame

2. apache virtual hosts config:

<VirtualHost *:443>
   DocumentRoot "/srv/http/mydomain"
   ServerName mydomain.nsupdate.info
   ServerAlias https://mydomain.nsupdate.info
   SSLEngine on
   SSLCertificateFile "/path/to/certificate.crt"
   SSLCertificateKeyFile "/path/to/private.key"
   SSLCACertificateFile "/path/to/bundle.crt"
</VirtualHost>

3. My /etc/hosts:

127.0.0.1       mydomain.nsupdate.info
127.0.1.1       hostname.localdomain      hostname
mydomain.nsupdate.info        mydomain.xyz

On redirection from the domain, the URL in the browser bar changes from mydomain.xyz to mydomain.nsupdate.info, with working HTTPS.

What I would like to do is retain my registered domain in the URL bar with HTTPS. I have tried playing with the apache Rewrite mod (this is enabled) but haven't managed to get this to work with my domain in the URL bar and working HTTPS. Does anyone have experience, or can help point me in the right direction on this? Perhaps there's something critical I'm misunderstanding. Many thanks.

Last edited by markJT (2018-10-20 17:18:34)

Offline

#2 2018-10-18 15:02:34

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED] Apache rewrite self-hosted DynDNS to registered domain https

A CNAME pointing to mydomain.nsupdate.info should be the correct record type for your domain.
Edit: If your domain provider allows you to set up Dynamic DNS directly, then that works as well.

I suggest you set up letsencrypt to generate and update your certificate automatically instead of using a third-party website.
https://wiki.archlinux.org/index.php/Certbot#Webroot

Last edited by progandy (2018-10-18 15:08:19)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#3 2018-10-20 13:27:19

markJT
Member
Registered: 2018-10-18
Posts: 13

Re: [SOLVED] Apache rewrite self-hosted DynDNS to registered domain https

Thanks for the reply: I've done as you suggest and switched to LetsEncrypt. I had tried this about a year ago but at the time the CLI for certbot didn't seem to recognise '.xyz' domains so I couldn't get it working. Works perfectly now.

I've also changed my DNS record type from URL Redirect to CNAME. Unfortunately the problem remains: the URL switches to mydomain.nsupdate.info on load. The web interface for my domain is a bit lacking in config options, but currently looks like:

Host Name: www
Record Type: CNAME (Alias)
Address: mydomain.nsupdate.info
Priority:

An extended look at my http-vhosts.conf which also shows port-80 redirecting to 443:

<VirtualHost *:443>
   DocumentRoot "/srv/http/mydomain"
   ServerName mydomain.nsupdate.info
   ServerAlias mydomain.xyz
   SSLEngine on
   SSLCertificateFile "/path/to/certificate.crt"
   SSLCertificateKeyFile "/path/to/private.key"
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "/srv/http/mydomain"
   ServerName mydomain.nsupdate.info
   ServerAlias mydomain.xyz
   Redirect "/" "https://mydomain.nsupdate.info"
</VirtualHost>

I'm going to continue to attempt working out the right configuration for CNAME and/or Apache Rewrite mod to see if either of those work..

Offline

#4 2018-10-20 17:14:26

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED] Apache rewrite self-hosted DynDNS to registered domain https

   Redirect "/" "https://mydomain.nsupdate.info"

That is the wrong domain.
You might also have to wait some time until the DNS change is recognized by your browser.
A third problem could be an automatic redirect set up in the software you are running on your server (e.g. wordpress).


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#5 2018-10-20 17:17:54

markJT
Member
Registered: 2018-10-18
Posts: 13

Re: [SOLVED] Apache rewrite self-hosted DynDNS to registered domain https

Thank you! I had just that minute discovered the same thing - was just typing this response:

Solved!

<VirtualHost *:443>
   DocumentRoot "/srv/http/mydomain"
   ServerName mydomain.nsupdate.info
   ServerAlias www.mydomain.xyz
   SSLEngine on
   SSLCertificateFile "/path/to/certificate.crt"
   SSLCertificateKeyFile "/path/to/private.key"
</VirtualHost>

<VirtualHost *:80>
   DocumentRoot "/srv/http/mydomain"
   ServerName mydomain.xyz
   Redirect permanent / https://www.mydomain.xyz
</VirtualHost>

Essentially I think it was just tweaking the bottom redirect line. I previously thought that redirecting towards the nsupdate.info domain would redirect to the service on port 443 above, lending it the alias mydomain.xyz, but I guess that is what was also retaining the URL in the URL bar.

Thank you ^_^

Offline

#6 2018-10-20 17:47:32

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: [SOLVED] Apache rewrite self-hosted DynDNS to registered domain https

I'm glad you got it working.


Redirect sends the URL you write there to your browser and then the browser will close the connection and connect to the new URL.

Last edited by progandy (2018-10-20 17:48:10)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

Board footer

Powered by FluxBB