Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

domain.com >> www.domain.com #691

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

Closed
RonAlmog opened this issue Sep 3, 2020 · 10 comments
Closed

domain.com >> www.domain.com #691

RonAlmog opened this issue Sep 3, 2020 · 10 comments
Labels
kind/question Issue that might be transferred to Discussions

Comments

@RonAlmog
Copy link

RonAlmog commented Sep 3, 2020

As some people said, this works great, but only for subdomains. for my main domain it fails.
Regardless, I want both mydomain.com and www.mydomain.com to go to the same place, and not be separate, for seo reasons.
Whats the best way to achieve this?
I'm using the 3 container method, so if i copy the example from the wiki:

$ docker run --detach \
    --name your-proxied-app
    --env "VIRTUAL_HOST=subdomain.yourdomain.tld" \
    --env "LETSENCRYPT_HOST=subdomain.yourdomain.tld" \
    --env "[email protected]" \
    nginx

And the 'subdomain' in my case is www, Then my question is: how do i add the top level domain (yourdomain.tld) and how do i cause all traffic from it to be redirected to www.yourdomain.tld ? (or vice versa, would be good as well)
Thanks!

@Mesqualito
Copy link

Mesqualito commented Sep 3, 2020

Same questions on my side - plus: how would it be able to proxy additional domains (www.yourdomain1.com, yourdomain1.com, www.yourdomain2.com, mysub.yourdomain2.com...) to one http/80-container with an .env-configuration.file and get additional certificates for them, too?

There are already answers, but it's not working on my docker host actually:

And can all subdomains be linked to the top domain with a wildcard (*.yourdomain1.com to cover www.yourdomain1.com, yourdomain1.com, mysub.yourdomain1.com ...)?

@buchdag
Copy link
Member

buchdag commented Sep 3, 2020

@RonAlmog the answer is in the documentation

#625 is an issue with pretty much zero info about what fails, how and why. This project should work for domains + subdomains, I personally have multiple domain + subdomain(s) setups in production and all are working fine.

@Mesqualito please don't post the same question in multiple issues. If the method described in the docs isn't working you are either encountering a yet unidentified bug or misconfiguring something somewhere that prevents Let's Encrypt from issuing you a certificate.

nginx-proxy/nginx-proxy#1369 is a pull request that hasn't been merged to nginx-proxy so this feature isn't actually available.

And can all subdomains be linked to the top domain with a wildcard (*.yourdomain1.com to cover www.yourdomain1.com, yourdomain1.com, mysub.yourdomain1.com ...)?

Nope, as wildcard certificates aren't supported.

@RonAlmog
Copy link
Author

RonAlmog commented Sep 3, 2020

Thanks @buchdag , you're absolutely right. I followed the documentation (just comma separate the domain, subdomain) and it works! Both mywebsite.com and www.mywebsite.com are now working fine with ssl.
The only question left for me is how to redirect one of them to the other. for example, every call to mywebsite.com should to to www.mywebsite.com . I used to do this in nginx.config, but now it's automatic so i'm a bit lost...

@shiz0
Copy link

shiz0 commented Sep 11, 2020

@RonAlmog
Check out my answer in the PR linked above:
nginx-proxy/nginx-proxy#1369 (comment)
With that nginx.tpl I am running multiple sites, each with subdomains and redirects, all with ssl. Working like charm. ❤️
Apart from the tpl it's (as of right now) even with nginx-proxy master.
@Mesqualito Did you try that as well? If yes, I'd be curious about what failed.

@buchdag
Copy link
Member

buchdag commented Sep 17, 2020

@RonAlmog the remaining question concerns nginx-proxy/nginx-proxy.

nginx-proxy/docker-letsencrypt-nginx-proxy-companion only concern is the automatic issuance / naming of certificate and the reloadinf of the proxy / docker-gen so that the SSL configuration is enabled and active.

Is it okay for you if I close this issue ?

@RonAlmog
Copy link
Author

@shiz0 , thanks for your suggestion, but since those tmpl files are foreign language for me, i need clear directions what to do.
are you suggesting to replace the tmpl file that is in this project with your version? which one exactly, there are 2 there.
And one more questions: how do you set which one will be active, will website.com go to www.website.com , or vice versa?
thanks.

@shiz0
Copy link

shiz0 commented Sep 18, 2020

The redirect issue is actually not a problem of this project (the companion), but of nginx-proxy itself.
There's a nginx.tmpl file in nginx-proxy, which is responsible for how the vhost configs (among other stuff) are created.
You can try to use my nginx.tmpl file with a three container setup, as this works for me without problems.
The configured vhost is the primary site, all vhost_aliases are redirected to it.
But I feel like this is not the right place to discuss this, as it's not companion related.

@buchdag buchdag added nginx-proxy issue kind/question Issue that might be transferred to Discussions labels Sep 24, 2020
@Elektropepi
Copy link

@shiz0 Using your file as template for my docker-gen installation, I can confirm it works perfectly.

In the end, my environment variables looked like this, and all variants of website.test, othersite.com redirected to https://website.test.

environment:
            - VIRTUAL_HOST=website.test
            - VIRTUAL_HOST_ALIAS=othersite.com,www.othersite.com,www.website.test
            - LETSENCRYPT_HOST=website.test,othersite.com,www.othersite.com,www.website.test

@geocine
Copy link

geocine commented Dec 22, 2020

@shiz0 did you pr your .tmpl file on the upstream?

@shiz0
Copy link

shiz0 commented Dec 22, 2020

@shiz0 did you pr your .tmpl file on the upstream?

As of now I did not, as the main work for that feature was done by @dannycarrera in nginx-proxy/nginx-proxy#1369 and I just did some fixes to make it work properly as intended. So it felt wrong to merge his work and my changes and start a new PR myself, but instead asked him to update his PR with my fixes.
As of now this did not happen unfortunately, so yes, maybe I will create a PR myself sometime to try and get this merged finally.

@buchdag buchdag closed this as completed May 16, 2021
@nginx-proxy nginx-proxy locked and limited conversation to collaborators May 16, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
kind/question Issue that might be transferred to Discussions
Projects
None yet
Development

No branches or pull requests

6 participants