Can't redirect to specific port using docker-compose + proxy

SYSTEM INFORMATION
OS type and version debian 10
Webmin version 2.001
Virtualmin version 7.3.1

Hello,

I tried to follow the excellent idea/tutorial by @beat to make a redirection from my domain to a specific port to a docker container.

Everything seems to work well on the docker side, as using myip:3000 sends me to the service.

My first step was to replace the virtual host section of my domain with beat’s snippet. (and changing the values)

After doing that, when I go to configure website, I can’t access the file anymore, it looks like that I’m on the For default server page instead on being on my virtual server. So there is no more an option to edit my apache conf file. (However checking through the terminal, I can see that the file is still here)

<VirtualHost 192.168.1.17:80>
    ProxyPreserveHost on

    # Ensure that encoded slashes are not decoded but left in their encoded state.
    # http://doc.gitlab.com/ce/api/projects.html#get-single-project
    AllowEncodedSlashes NoDecode

    <Location />
        # New authorization commands for apache 2.4 and up
        # http://httpd.apache.org/docs/2.4/upgrading.html#access
        Require all granted

        #Allow forwarding to docker container:
        ProxyPassReverse http://192.168.1.17:3000/
    </Location>

    # Apache equivalent of nginx try files
    # http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files
    # http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
    RewriteEngine on
    RewriteRule .* http://192.168.1.17:3003%{REQUEST_URI} [P,QSA,NE]


</VirtualHost>
<VirtualHost 192.168.1.17:443>
    ###Ref: https://gitlab.com/gitlab-org/gitlab-recipes/blob/8-2-stable/web-server/apache/gitlab-ssl-apache24.conf

    ProxyPreserveHost on

    # Ensure that encoded slashes are not decoded but left in their encoded state.
    # http://doc.gitlab.com/ce/api/projects.html#get-single-project
    AllowEncodedSlashes NoDecode

    <Location />
        # New authorization commands for apache 2.4 and up
        # http://httpd.apache.org/docs/2.4/upgrading.html#access
        Require all granted

        #Allow forwarding to docker container:
        ProxyPassReverse http://192.168.1.17:3000/
    </Location>

    # Apache equivalent of nginx try files
    # http://serverfault.com/questions/290784/what-is-apaches-equivalent-of-nginxs-try-files
    # http://stackoverflow.com/questions/10954516/apache2-proxypass-for-rails-app-gitlab
    RewriteEngine on
    RewriteRule .* http://192.168.1.17:3003%{REQUEST_URI} [P,QSA,NE]

    RequestHeader set X_FORWARDED_PROTO 'https'
    RequestHeader set X-Forwarded-Ssl on
</VirtualHost>

When I try the https://mydomain.com, I am told there is a certificate anomaly by the browser and if I continue, I get redirected to the first virtualhost of my server.

Thanks a lot for any help !

Cheers,

Hello,

You need to configure a balancer and also skip on SSL certificate check, for example:

<Proxy balancer://path1>
    BalancerMember https://127.0.0.1:3000
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerExpire off
</Proxy>
ProxyPass /path1 balancer://path1

Although, we recommend using Virtualmin Pro to do it for you with Proxy Paths feature.

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.