0

I have a subdomain that I need to redirect to a completely different domain. This subdomain was set up as a CNAME that pointed to Shopify, now it's being removed completely.

Lets say the subdomain is shop.example.com

I've now set an A record for that to point to the primary IP address.

From what I've read on here, I can add the following to my NGNIX file..

    listen 80;
    server_name https://shop.example.com;
    return 301 https://example2.com;

And put this inside the server block.

This server is provisioned on Forge and already has

    listen 443 ssl http2;
    listen [::]:443 ssl http2;

At the top of the server block. Do I still need the listen 80;?

And does this look correct?

Many thanks.

1 Answer 1

0

Port 80 is expected to run HTTP - for HTTPS you need to use port 443. The same server block can have multiple listen directives to listen on multiple ports.

But the problem in your config is that server_name can contain only domain names - but not protocols, so you have to remove the https:// prefix.

Now, to the questions:

  1. Since the recent versions of the major browsers usually first try HTTPS - you can stop listening on port 80 if you do not want to. But it is not wrong if you continue listening.
  2. Without looking at your full configuration we can't say whether it is correct or not.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.