Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx: add www subdomain & redirect as default #58

Open
cybrmakr opened this issue Oct 8, 2022 · 3 comments
Open

nginx: add www subdomain & redirect as default #58

cybrmakr opened this issue Oct 8, 2022 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@cybrmakr
Copy link

cybrmakr commented Oct 8, 2022

NGINX forwarding

It's common to have a server blocks regarding forwarding like this :)

server {
listen 80;
server_name www.example.com;
return 301 http://example.com$request_uri;
}

server {
listen 80;
server_name example.com;
...
}

Would be amazing if this could be added to Ansible in order to configure this in nginx automatically.
Same applies to HTTPS, right? Also, is it possible to enter subdomains in the Ansible script for gettings certificates via certbot for both,
www.example.com as well as example.com itself.

Currently when opening browsing the www. version nginx default page appears. :)

@Nutomic
Copy link
Member

Nutomic commented Oct 8, 2022

You are more than welcome to make a pull request with these changes.

@ticoombs
Copy link
Collaborator

ticoombs commented Sep 4, 2023

While this seems like a good example, it is actually more trouble than it's worth.
As now that it's 2023, not everyone uses the full domain.

While it's true that for some this would be a benefit, the majority (looks at instance federation list) are already using subdomains. adding www.subdomain.example.com as a redirect seems redundant. Unless! If browsers still try www automatically for existing subdomains then this would be needed.

If we want to tackle this issue, having a section behind an {% if www_enabled is true %} and have it as www.{{domain}} would suffice

@codyro
Copy link
Collaborator

codyro commented Sep 4, 2023

Let's Encrypts allows certificates to have multiple SANs, so if we wanted to support this, we could do something more flexible.

Maybe we can have a SAN list that will get used when certbot requests the initial certificate?

pseudo-code

ssl_san:
  - www
  - staging
  - testing

The above would generate a valid certificate for www.{{ domain }}, staging.{{ domain }}, etc.

I don't necessarily think the above is the best approach, but making it limited to "do you want www or not" doesn't feel right to me.

Whether the juice is worth the squeeze, I don't know. The above proposal changes can be done quickly, though.

@ticoombs ticoombs changed the title Advance NGINX configuration nginx: add www subdomain & redirect as default Dec 16, 2023
@ticoombs ticoombs added enhancement New feature or request help wanted Extra attention is needed labels Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants