Nope, They are wrong. It is not working.
Thanks for that! That is exactly the experience I have. But they sent me a screenshot of digitallysovereign.org.. could it be we all are having the same caching issue?
Ok, I see, The problem is not the redirect, it is HTTPS,
The redirect server for namecheap does not respond to HTTPS requests, and all my browsers force HTTPS mode, I did some testing and it turns out the server would just hang up any connections made to HTTPS (or port 443) while it responds normally to an HTTP request.
in hindsight, this is why I manage my redirects via nginx (or nginx proxy manager to be specific) I can just use certbot to have certificates for all the hosts and redirect users no matter http or https.
From the namecheap docs:
NOTE: Redirecting with a secure connection (HTTPS) is only possible to a different destination domain (e.g. http://www.domain.tld to https://www.anotherdomain.tld). If you need this type of redirect (HTTP >> HTTPS) or vice versa (HTTPS >> HTTP) within the same domain name (http://domain.tld to https://domain.tld) , it must be set up via the .htaccess file or Namecheap SSL plugin in cPanel, provided an SSL certificate is installed .
Please note that redirecting from https://domain1.tld to https://domain2.tld will also require both domains to have SSL certificates installed.
From these instructions it seems like it should have worked seamlessly.. I assumed namecheap would provide the SSL cert for the old domain. But I guess not!
Better to do this myself on the old mailcow server as it turns out. Lesson learned, which I’ve documented in a runbook.
I also shared a nifty way to do this all within discourse as well. That’d be even more straightforward than doing it via nginx
Yes! Doing it in Discourse is the better solution because it doesn’t create a dependency on nginx, and it works on a multisite or standard install! It took me a minute to wrap my head around why you would do that and how it would work. Here’s the code snippet you shared.
I haven’t actually tried it, but presumably these are the steps:
- add this code to the end of your
app.ymlfile, adjusting the domain names according to your setup - rebuild discourse as per usual
- if you are moving servers, change DNS of old domain to point to your new server
- profit!
hooks:
after_code:
- exec:
cd: $home/plugins
cmd:
- git clone https://github.com/discourse/docker_manager.git
after_web_config:
- replace:
filename: /etc/nginx/nginx.conf
from: /sendfile.+on;/
to: |
server_names_hash_bucket_size 64;
sendfile on;
- file:
path: /etc/nginx/conf.d/discourse_redirect_1.conf
contents: |
server {
listen 80;
listen 443 ssl;
server_name old-domain.com;
return 301 $scheme://new-domain.com$request_uri;
}
after_ssl:
- replace:
filename: "/etc/runit/1.d/letsencrypt"
from: /--keylength/
to: "-d old-domain.com --keylength"
Step 0 will be to read both the files, there are some lines here that may be redundant, but are placed so that you get some reference regarding the placement of the relevant stanza.