vfarcic / docker-flow-stacks

85 stars 60 forks source link

Setting up portainer with docker-flow proxy on a sub domain + URL didn't worked #19

Closed vboufleur closed 6 years ago

vboufleur commented 6 years ago

Hi!!

I tried setting up Portainer with docker-flow proxy by following the way you do it on docker-flow-stacks/docker/portainer-df-proxy.yml, but I couldn't set it up on a URL with a sub domain too.

I tried setting up the label com.df.servicePath with and without com.df.reqPathSearchReplace together with com.df.serviceDomain, none of them worked. On all the options portainer was just available on the root url specified on com.df.serviceDomain.

When I tried accessing the sub URL specified on com.df.servicePath I've got an error 404 back, when I tried with both com.df.servicePath and com.df.reqPathSearchReplace I've got an error 400 back.

You know why it happened and/or the right way to do it? Thanks in advance!

sagar-chandarana commented 6 years ago

The goal here is to be able to mount different services on different servicePath. Eg. domain/portainer -> portainer domain/blog -> WordPress

The domain remaining the same for all such services. How can we set this up? Thanks

vfarcic commented 6 years ago

@sagar-chandarana If the domain is the same for all those services, they must be distinguished by a path or you can use reqPathSearchReplace to rewrite a path before forwarding it further. However, that would mean that the paths in those applications are relative. Can you confirm that? Also, why do you have to have the same domain? Having sub-domains is virtually free and allows much more flexibility.

vfarcic commented 6 years ago

@vboufleur If I remember correctly, you have to tell Portainer to use a proxy when using paths instead of (sub)domains. Did you configure Portainer with the proxy settings?

sagar-chandarana commented 6 years ago

@vfarcic let me understand this a bit with an example. 2 services:

Is it possible to mount these services to different paths on the same domain? If so, what would be labels for it? servicePath=/blog and reqPathSearchReplace=/blog:/ - would this be correct?

Also, the problem with subdomains is SSL - as we are creating on-demand instance names (subdomain names). Is there an automated way to acquire SSL certs from let's encrypt (inside docker-flow itself) as we declare different subdomains?

EDIT: may be just acquiring wildcard SSL early on should be enough. Still mounting and changing different paths on the same domain would be very useful

vfarcic commented 6 years ago

@sagar-chandarana Yes. servicePath=/blog and reqPathSearchReplace=/blog:/ is correct, assuming that the end-service understands the concept of relative paths. If, for example, its links are hard-coded to be /, or /something, then DFP will not help with reqPathSearchReplace for anything but the first request. As an example, imagine a web page is made with a logo that always sends you to /? Using relative paths in applications is a good practice, but that doesn't mean that everyone is following it. In some cases, apps have a special setting to add some kind of a proxy prefix to avoid absolute paths.

The short version: your assumption about reqPathSearchReplace is correct if the app behind it supports relative paths.

For Let's Encrypt certs, you might want to check https://github.com/hamburml/docker-flow-letsencrypt and http://proxy-letsencrypt.dockerflow.com/.

sagar-chandarana commented 6 years ago

@vfarcic Got it. API endpoints are atomic so relative paths are not an issue. Will take a look at the links regarding SSL. Thanks for quick responses! @vboufleur and I work together, can close this issue.