-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Support proxying multiple paths to different backends #254
Conversation
Another thing that would need to happen if there is a desire to merge this PR is an update to |
And I suppose some tests now that #246 has been merged. 👍 |
Looks like |
@md5 What do you think about combining this functionality with #259 so that you can do all of this by just setting the Something like:
There have been a few PRs for implementing parts of this functionality separately, but I think it would be easier for users if the syntax was combined. Thoughts? |
I think the idea of combining At this point, I'd probably start moving toward a JSON config format, similar to what |
Yeah, originally I didn't like the idea of having the port part in there. Starting to change my mind because the port for I forgot about the protocol change piece to #259 as well. I'm fine with keeping that out for now as well too. |
It looks like some work would need to be done in Namely,
I'm not sure whether that's the actual code that would be needed; it seems like there could need to be a check to see if the |
It just opened nginx-proxy/docker-gen#126 to add |
Hello. I am not familiar with the netiquette within github, so I am not unsure if "+1" is welcome here. But I'll give it a try. :) The feature would be really good in the way you propose. And it appears to be consistent/logical in the way the reverse-proxy is configured so far. The type of setup with a VIRTUAL_PATH can be very common in an environment with a DynDNS-Service in combination with a temporary IP-address. Usually you have only one subdomain referring to your current IP-address/service. A VIRTUAL_PATH option would really help in this environment to reach different containers. P.S.: THX for engagement in the reverse proxy! |
`first` returns interface{}, not string, so it makes strings.Trim choke. The call to `or` returns a string in both cases, which `trim` can handle.
ea49fae
to
f7d9156
Compare
I've done some work toward getting this working with One thing I realized is that there may be some differences of opinion as to how this feature should work. Specifically, I could see some users expecting the path to be stripped from the URL that is received before proxying it to the backend while others might want it to pass through unchanged. As it stands now, the code will pass through the path unchanged. Whichever option is chosen, the backend application will need to know that it's running at |
We may want to pass an |
I think setting |
Don't you think some users would want it one way and some the other way? |
@md5 The use cases I've heard so far are to support exposing multiple backends where someone only has one domain name. Making the path based proxying transparent to the backends seems simpler for users to me. I.e they would be able to start there backends the same as if they were not using path based proxying (hopefully). What do you think? |
I think that having a backend service that responds at However, whichever option is chosen is not going to be transparent to the backend. Either way, the backend needs to know it's at |
I'm taking a look again at supporting When I was using In order to get the same structure with a single variable, I need to be able to group containers by the first part of the split containers.reject { |c| c.Env['VIRTUAL_HOST'].empty? }
.group_by { |c| c.Env['VIRTUAL_HOST'].split('/', 2)[0].strip }
.each do |h,h_containers|
puts "server { server_name #{h};"
h_containers.group_by { |c| c.Env['VIRTUAL_HOST'].split('/', 2)[0].try(:strip) || '/' }
.each do |p,_|
upstream = "#{h}-#{Digest::SHA1.digest(p)}"
puts "location #{p} { proxy_pass http://#{upstream}/; }"
end
puts "}"
end Doing this with If we didn't have to deal with the comma-separated list in
However, I'm at a loss as to how to support the |
I've been thinking that it might be worth considering making |
@md5 Yeah. I've had the same thoughts recently and have implemented |
Just stumbled upon this PR because I actually need this feature, too. |
Any particular reason this is still not merged? |
@andreycizov The reasons are exhaustively covered in the previous comments. |
Very much would like to see this also. |
Giving the fact that this is a very much requested feature that has been in stand-by for 2 years now because @jwilder considers the configuration template as not making "most sense" can we please get a pass and merge this? It will only affect people whom are interested in this feature, which currently is non-existent. I think writing a couple more ENV variables trumps the lack of existence for this feature. |
@adrianilie9 I haven't used this image in almost 3 years, so I'm not going to be working on this PR again. The only reason I haven't closed it is that I know people want the feature. |
I took another version of this feature and I rebased it against the current master in case some is interested |
Incorrect trimming did lead to empty domains being created on space separated domains or with comma trailed LETSENCRYPT_HOST environment variable. This in turns led to the container being caught in an endless loop trying to delete /etc/nginx/certs nginx-proxy#254 nginx-proxy#288
@rodrigoaguilera It works pretty well thanks a lot, but I was wondering why the path is passed to the target container as well? Would it be difficult to strip the virtual path off the requests before redirecting to Example: I'd like to serve a Or is there a nginx override I might create to make it working without additional code? |
any updates to this? |
1 similar comment
any updates to this? |
Any updates here? @md5 i really need this feature. |
Unbelievable! It's been 5 years since this pr is created. |
I have successfully ported this feature into a private fork. If anyone is still interested, i can make a public one. Just let me know. |
Why it hasn't been merge onto the master branch yet? |
@adrianilie9, yes, please share it publicly and send as another PR. I'd love to use it as well. BTW: Did you resolve issues that md5 mentioned?
|
@adrianilie9 could you share your fork please? |
+1 vote for obtaining a feature to specify different virtual paths/locations on the same host/server that are forwarded to different containers. |
Hi Guys, how is thing PR going ? It really super helpful |
Any updates on this? |
Is this project abandoned? How come this PR hasn't been added in 6 years? |
The lack of updates to this PR should be quite clear from the comment history. I'm not sure there's anything more to say on that. As for whether this project is abandoned, it looks like @jwilder made some updates in late 2020, but this is clearly not a project that is receiving feature updates. It looks like all recent PRs that were reviewed and merged are hotfixes to existing functionality. |
This features has been added to the It's available now on the |
I'm finally opening a PR to review my branch for supporting multiple paths with
VIRTUAL_PATH
. I think that some of the duplicated code could probably be made a bit more DRY, but this code seems like a good starting point for a discussion to me.A couple things are happening in this patch.
VIRTUAL_PATH
is being used within the containers with a sharedVIRTUAL_HOST
upstream
name and theproxy_pass
statementIn the event that
VIRTUAL_PATH
is not set for/
within the context of a particularVIRTUAL_HOST
, a 404 is returned. This should possibly be a 503 instead, but I didn't want to hold up the discussion of this patch any longer (it's been over a year since I first created this branch).Known issues that might need to be addressed before merging:
/
instead of 404VIRTUAL_HOST
haveVIRTUAL_PATH
set but others do notFixes #33