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!
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 ...)?
@RonAlmog the answer is in the documentation
@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.
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...
@RonAlmog
Check out my answer in the PR linked above:
https://github.com/nginx-proxy/nginx-proxy/pull/1369#issuecomment-667191639
With that nginx.tpl I am running multiple sites, each with subdomains and redirects, all with ssl. Working like charm. :heart:
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.
@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 ?
@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.
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.
@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
@shiz0 did you pr your .tmpl file on the upstream?
@shiz0 did you pr your
.tmplfile on the upstream?
As of now I did not, as the main work for that feature was done by @dannycarrera in https://github.com/nginx-proxy/nginx-proxy/pull/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.
Most helpful comment
@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-proxyso this feature isn't actually available.Nope, as wildcard certificates aren't supported.