I have the following docker compose file:
version: "3.9"
services:
php:
image: phpimage
ports:
- 80:80
phpmyadmin:
image: phpmyadminimage
ports:
- "8080:80"
environment:
- PMA_HOST=mysql
mysql:
image: mysqlimage
command: mysqld --sql_mode="NO_ENGINE_SUBSTITUTION"
And everything works fine. The one thing that annoys me though is that when I access phpmyadmin through the browser, I need to go to http://localhost:8080.
Is there anyway I can set up an apache rule, so that instead of the above I can simply enter http://localhost/phpmyadmin?
I've been messing about with redirects and reverse proxies but not got anything to work yet
Update:- I've been trying stuff like this:
<VirtualHost *:80>
ServerName localhost/phpmyadmin
ProxyPass / http://phpmyadmin
ProxyPassReverse / http://phpmyadmin
</VirtualHost>
CodePudding user response:
LocalHost is a default "link" that is configured on your computer that points directly to your own ip 127.0.0.1, and can be configured within your computer's Hosts file. Remembering that every new link you add to point to your machine's ip will no longer access the internet.
Follow link to help you. https://www.hostinger.com/tutorials/how-to-edit-hosts-file
CodePudding user response:
You have to setup the docker network correctly. See How to reach docker containers by name instead of IP address?
As already mentioned you have to use the correct hostname based on your docker compose configuration.