Redirect sub domain to a container (Apache/Gitlab)

Hi !

I’ve an Apache container which redirect these sub domain : &
These 2 sub domain are redirect to different website folder /www/1 /www/2 thanks to Apache vhost.

But now i installed a Gitlab container (port 8080), and i want to join it by (without the port).

How can i redirect to this container ?

Thank you ! Guiguir68

The bit you probably need is the Apache ProxyPass directive. Create a new virtual host and set it to proxy to the container.

1 Like

Thank you Dmaze ! You have guided me well !

In my case, this is my apache2/sites-availabled/gitlab.conf :

<VirtualHost *:80> ProxyPreserveHost On ProxyRequests Off ServerName ServerAlias ProxyPass / ProxyPassReverse / </VirtualHost>

And don’t forget…

sudo a2ensite gitlab sudo a2enmod proxy sudo a2enmod proxy_http sudo service apache2 restart

Thanks again !


You could also use this to redirect subdomains to containers dynamically:

This Nginx-based tool automatically redirects requests to the appropriate container (based on the given subdomain using the VIRTUAL_HOST container environment variable).

I wrote a tutorial about it:

For your use case, you would simply run the nginx-proxy container (port 80) and run the GitLab container (whatever port you like, provided it is exposed) with the “” environment variable.

@flopes have you heard of anything similar for apache, I don’t want to add nginx if I dont have to, seems unnecessary complexity.

Hi lindsaymacvean,

I have not heard of anything similar using Apache, couldn’t find anything relevant too.