Is it possible to define ip-based Vhost?

Hi there!
I work with a Windows10 laptop on which I cannot have the admin rights.
So I cannot update the hosts file nor I can define a new DNS to setup the auto-DNS feature.

Although not user friendly, I see the IP-Based Vhost definition as the best quick win to use devilbox.
In other word I access VHost through IP addresses and not domain.
I guess this is totally possible since we can customize virtualhost file for each projects.

From here I am stucked because of my lack of knowledge on network.
I defined a dedicated template for Apache-24 in myproject/.devilbox and although the myproject.conf file is indeed modified, I cannot access my application.

I have

<VirtualHost 127.0.0.2:4000>
    ServerName third-project.loc
    Protocols  http/1.1

    CustomLog  "/var/log/apache-2.4/third-project-access.log" combined
    ErrorLog   "/var/log/apache-2.4/third-project-error.log"

    DocumentRoot "/shared/httpd/third-project/htdocs"
    <Directory "/shared/httpd/third-project/htdocs">
        DirectoryIndex index.php

        AllowOverride All
        Options All

        RewriteEngine on
        RewriteBase /

        Order allow,deny
        Allow from all
    </Directory>

    ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/shared/httpd/third-project/htdocs/$1
</VirtualHost>

and added - “127.0.0.2:4000:4000” in the port section of the php service (docker-compose), but I still get an ERR_EMPTY_RESPONSE from my browser.

Any Idea on where I am mistaking?

Thx for your help.

That would make the vhost available on 127.0.0.2 if this exists inside the HTTP container (Not your host computer)

This is parsing the requests to localhost on the HTTP container (Which is not the PHP container).

Think of each container as a separate server. 127.0.0.1 is always local for each server.

So by that, none of the configuration will work.

1 Like