nginx-proxy / nginx-proxy/nginx-proxy
How to redirect all traffic to only ONE host containter?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 19.9k
- Forks
- 3k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 1
Description
Excellent job guys! I'm very impressed with your work!
Where in the code I could modify the internal router that routes the SNI "website1.com" TO container "website1" created with VIRTUAL_HOST=website1.com... So it can redirect all traffic to the SAME container, say: "localhost"???
EX:
exemple.com => host container:"localhost"
mycustomdomain.com => host container:"localhost"
anothercustomdomain.com =>host container:"localhost"
ALL 3 HOST CONTAINER ARE THE SAME!
We're developing an app like "wix.com, squarespace.com" to generate (maybe millions of) websites on the fly with HTTPS support. This docker project with "docker-letsencrypt-nginx-proxy-companion" is the closest I've found to meet our criteria to solve our TLS termination problem:(How to host thousands of custom domains with SSL).
The only dilemma is this project was designed for websites with different code
EX:
website1.com => custom code for website1
website2.com => custom code for website2
Each websites are separated with their own code; which is logical.
The problem is our app is already polymorphic(will pull the custom data according to the hostname)
EX:
website1.com => uses the SAME code to build website1 with DIFFERENT data according to the hostname.
website2.com => uses the SAME code to build website2 with DIFFERENT data according to the hostname.
Long story short: We cannot have 1,000,000 containers: website1,website2,...website100001; it makes no sense. It's all the same code! We just need "on the fly TLS termination". I hope to decrypt/generate all SSL on the fly and bump all the traffic TO ONE CONTAINER for our code to do the rest of the magic.
I think I'm getting close. I've found in /nginx.tmpl
line 117: I modified
{{ $host := trim $host }}
{{ $is_regexp := hasPrefix "~" $host }}
{{ $upstream_name := when $is_regexp (sha1 $host) $host }}
for
{{ $upstream_name := "thisismysupertest.com" }}
line 276: To be used here
server {
[...]
location / {
[...]
include uwsgi_params;
uwsgi_pass {{ trim $proto }}://{{ trim $upstream_name }};
}
}
But I get a:
2018/01/19 03:15:32 [emerg] 1#1: invalid host in upstream "http://thisismysupertest.com" in /etc/nginx/conf.d/default.conf:80
or
2018/01/19 03:15:32 [emerg] 1#1: invalid host in upstream "http://172.18.0.3" in /etc/nginx/conf.d/default.conf:80
172.18.0.3 is the ip of thisismysupertest.com container
Any idea?
Thank you for your time :)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with nginx.tmpl, especially the upstream-name logic around line 117 and the uwsgi_pass usage around line 276. Inspect the generated /etc/nginx/conf.d/default.conf and verify that multiple hostnames can route to one container while nginx starts without an invalid upstream error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, nginx
- Domain
- backend, networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100