Is it possible to have 2 sites (1 www and 1 root) with Forge?
I have my site created with Forge at domain.com.
I have a staging site setup with Forge on the same server at staging.domain.com and have an A record with my DNS provider (Cloudflare) to point to the IP of my server.
This works great.
I added another site with Forge on my server at www.domain.com and created an A record similarly to staging.
However, if I visit www.domain.com, I automatically get redirected to domain.com with a status code of 301.
Thanks @Cronix for the suggestion. Unfortunately, there are no return statements (or redirects) in the nginx config. I checked the config for domain.com and staging.domain.com.
I have also replaced the A records with CNAME records hoping that could resolve it but it did not.
@awhite did you enable Let's encrypt or another SSL cert? Forge automatically adds the www subdomain into the "before" nginx configuration per default. You can checkout the config file in /etc/nginx/forge-conf/<<your site>>/before.
Yes, I noticed the same auto-generation when activating a certificate. I imported a certificate and it included 'www' so maybe that's how the configuration was created.
Rather than generating new certificates (1 for domain.com, 1 for staging.domain.com and 1 for www.domain.com), I simply commented out the redirect in each ssl_redirect.conf file.
I'm not sure of the pros/cons of 1 aggregated certificate vs. individual ones. My approach seems a little hacky so maybe I'll swap to individual certificates over the weekend.