Apache virtual host redirect for wordpress on localhost:8000 via www.example.com [closed]












-1















I'm moving 2 wordpress websites (one of them is a subdomain) to my local machine under docker containers for development.



I would like to access them in my development machine by their domain names using the hosts file, but I'm struggling to get my apache virtual hosts to work.



Let's say:

Site 1 is 'www.example.com'

Site 2 is 'sub.example.com'

Each have their own MySQL database and wordpress code base, setup on different docker-compose containers.



So:

Site 1: wwww.example.com on http://localhost:8000

Site 2: sub.example.com on http://localhost:8001

both work fine via localhost:8000 and localhost:8001



I altered my local hosts file to have:



127.0.0.1       localhost  
127.0.0.1 example.com www.example.com sub.example.com


I'm struggling to setup the apache virtual hosts for this situation,
this is what I've tried:



<VirtualHost *:80>
ServerName www.example.com
ProxyPass / http://localhost:8000/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>

<VirtualHost *:80>
ServerName sub.example.com
ProxyPass / http://localhost:8001/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>


Going directly to http://localhost:8000 and http://localhost:8001 works.



When I go to http://www.example.com I get the following error:




Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Apache/2.4.25 (Debian) Server at www.example.com Port 80




and on http://sub.example.com:




Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Apache/2.4.25 (Debian) Server at sub.example.com Port 80




Can someone point me in the right direction on how to setup the virtual hosts please?



Thank you










share|improve this question













closed as off-topic by Armali, tripleee, E_net4, Vadim Kotov, ewolden Nov 15 '18 at 11:04


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User." – Armali, tripleee, E_net4, ewolden

If this question can be reworded to fit the rules in the help center, please edit the question.

















  • The problem is deeper than I originally thought, I forgot to mention that apache is running in its own docker container. To solve the problem will involve knowledge of docker exposed ports, apache virtual hosts, hosts file, and correct wordpress settings e.g. table wp_options: home and siteurl. Would a re-worded question still be off-topic here?

    – Fab Sanchez
    Nov 15 '18 at 13:28
















-1















I'm moving 2 wordpress websites (one of them is a subdomain) to my local machine under docker containers for development.



I would like to access them in my development machine by their domain names using the hosts file, but I'm struggling to get my apache virtual hosts to work.



Let's say:

Site 1 is 'www.example.com'

Site 2 is 'sub.example.com'

Each have their own MySQL database and wordpress code base, setup on different docker-compose containers.



So:

Site 1: wwww.example.com on http://localhost:8000

Site 2: sub.example.com on http://localhost:8001

both work fine via localhost:8000 and localhost:8001



I altered my local hosts file to have:



127.0.0.1       localhost  
127.0.0.1 example.com www.example.com sub.example.com


I'm struggling to setup the apache virtual hosts for this situation,
this is what I've tried:



<VirtualHost *:80>
ServerName www.example.com
ProxyPass / http://localhost:8000/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>

<VirtualHost *:80>
ServerName sub.example.com
ProxyPass / http://localhost:8001/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>


Going directly to http://localhost:8000 and http://localhost:8001 works.



When I go to http://www.example.com I get the following error:




Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Apache/2.4.25 (Debian) Server at www.example.com Port 80




and on http://sub.example.com:




Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Apache/2.4.25 (Debian) Server at sub.example.com Port 80




Can someone point me in the right direction on how to setup the virtual hosts please?



Thank you










share|improve this question













closed as off-topic by Armali, tripleee, E_net4, Vadim Kotov, ewolden Nov 15 '18 at 11:04


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User." – Armali, tripleee, E_net4, ewolden

If this question can be reworded to fit the rules in the help center, please edit the question.

















  • The problem is deeper than I originally thought, I forgot to mention that apache is running in its own docker container. To solve the problem will involve knowledge of docker exposed ports, apache virtual hosts, hosts file, and correct wordpress settings e.g. table wp_options: home and siteurl. Would a re-worded question still be off-topic here?

    – Fab Sanchez
    Nov 15 '18 at 13:28














-1












-1








-1








I'm moving 2 wordpress websites (one of them is a subdomain) to my local machine under docker containers for development.



I would like to access them in my development machine by their domain names using the hosts file, but I'm struggling to get my apache virtual hosts to work.



Let's say:

Site 1 is 'www.example.com'

Site 2 is 'sub.example.com'

Each have their own MySQL database and wordpress code base, setup on different docker-compose containers.



So:

Site 1: wwww.example.com on http://localhost:8000

Site 2: sub.example.com on http://localhost:8001

both work fine via localhost:8000 and localhost:8001



I altered my local hosts file to have:



127.0.0.1       localhost  
127.0.0.1 example.com www.example.com sub.example.com


I'm struggling to setup the apache virtual hosts for this situation,
this is what I've tried:



<VirtualHost *:80>
ServerName www.example.com
ProxyPass / http://localhost:8000/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>

<VirtualHost *:80>
ServerName sub.example.com
ProxyPass / http://localhost:8001/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>


Going directly to http://localhost:8000 and http://localhost:8001 works.



When I go to http://www.example.com I get the following error:




Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Apache/2.4.25 (Debian) Server at www.example.com Port 80




and on http://sub.example.com:




Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Apache/2.4.25 (Debian) Server at sub.example.com Port 80




Can someone point me in the right direction on how to setup the virtual hosts please?



Thank you










share|improve this question














I'm moving 2 wordpress websites (one of them is a subdomain) to my local machine under docker containers for development.



I would like to access them in my development machine by their domain names using the hosts file, but I'm struggling to get my apache virtual hosts to work.



Let's say:

Site 1 is 'www.example.com'

Site 2 is 'sub.example.com'

Each have their own MySQL database and wordpress code base, setup on different docker-compose containers.



So:

Site 1: wwww.example.com on http://localhost:8000

Site 2: sub.example.com on http://localhost:8001

both work fine via localhost:8000 and localhost:8001



I altered my local hosts file to have:



127.0.0.1       localhost  
127.0.0.1 example.com www.example.com sub.example.com


I'm struggling to setup the apache virtual hosts for this situation,
this is what I've tried:



<VirtualHost *:80>
ServerName www.example.com
ProxyPass / http://localhost:8000/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>

<VirtualHost *:80>
ServerName sub.example.com
ProxyPass / http://localhost:8001/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>


Going directly to http://localhost:8000 and http://localhost:8001 works.



When I go to http://www.example.com I get the following error:




Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Apache/2.4.25 (Debian) Server at www.example.com Port 80




and on http://sub.example.com:




Service Unavailable

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Apache/2.4.25 (Debian) Server at sub.example.com Port 80




Can someone point me in the right direction on how to setup the virtual hosts please?



Thank you







apache localhost port virtualhost






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 11:37









Fab SanchezFab Sanchez

14




14




closed as off-topic by Armali, tripleee, E_net4, Vadim Kotov, ewolden Nov 15 '18 at 11:04


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User." – Armali, tripleee, E_net4, ewolden

If this question can be reworded to fit the rules in the help center, please edit the question.







closed as off-topic by Armali, tripleee, E_net4, Vadim Kotov, ewolden Nov 15 '18 at 11:04


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions about general computing hardware and software are off-topic for Stack Overflow unless they directly involve tools used primarily for programming. You may be able to get help on Super User." – Armali, tripleee, E_net4, ewolden

If this question can be reworded to fit the rules in the help center, please edit the question.













  • The problem is deeper than I originally thought, I forgot to mention that apache is running in its own docker container. To solve the problem will involve knowledge of docker exposed ports, apache virtual hosts, hosts file, and correct wordpress settings e.g. table wp_options: home and siteurl. Would a re-worded question still be off-topic here?

    – Fab Sanchez
    Nov 15 '18 at 13:28



















  • The problem is deeper than I originally thought, I forgot to mention that apache is running in its own docker container. To solve the problem will involve knowledge of docker exposed ports, apache virtual hosts, hosts file, and correct wordpress settings e.g. table wp_options: home and siteurl. Would a re-worded question still be off-topic here?

    – Fab Sanchez
    Nov 15 '18 at 13:28

















The problem is deeper than I originally thought, I forgot to mention that apache is running in its own docker container. To solve the problem will involve knowledge of docker exposed ports, apache virtual hosts, hosts file, and correct wordpress settings e.g. table wp_options: home and siteurl. Would a re-worded question still be off-topic here?

– Fab Sanchez
Nov 15 '18 at 13:28





The problem is deeper than I originally thought, I forgot to mention that apache is running in its own docker container. To solve the problem will involve knowledge of docker exposed ports, apache virtual hosts, hosts file, and correct wordpress settings e.g. table wp_options: home and siteurl. Would a re-worded question still be off-topic here?

– Fab Sanchez
Nov 15 '18 at 13:28












2 Answers
2






active

oldest

votes


















0














You can try checking the logs located in var/log/httpd(You can also try sudo locate access.log) for the actual error that is happening.



The one thing you are missing is ProxyPassReverse which will rewrite the URL if your website is redirecting. With it your configuration will look something like this



<VirtualHost *:80>
ServerName www.example.com
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>

<VirtualHost *:80>
ServerName sub.example.com
ProxyPass / http://localhost:8001/
ProxyPassReverse / http://localhost:8001/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>





share|improve this answer



















  • 1





    I added the ProxyPassReverse, restarted apache, same error, checked the logs and realised that my apache is in a docker container also, so localhost defines the apache docker localhost and not the host machine's localhost... I changed localhost:8001 to host_machine_ip:8001 then it seemed to work. I need to do more tests as a new issue has appeared,,, thank you for the help.

    – Fab Sanchez
    Nov 15 '18 at 9:18



















0














I understand that my question may be off-topic here, but since I managed to solve my problem, I hope you will allow my answer to remain here so that it may help someone else.



I failed to mention that the apache server was running in its own Docker container.



This is what I did to solve the problem:



In the host machine:



Include www.example.com, example.com and sub.example.com in the hosts file:



127.0.0.1       localhost  
127.0.0.1 example.com www.example.com sub.example.com


In the apache docker container:



Since apache is running in its own docker container, localhost:8000 points to apache docker container's localhost which is incorrect here.

It needs to point to the host machine's ip address, which in my case is 192.168.1.100.



<VirtualHost *:80>
ServerName www.example.com
ProxyPass / http://192.168.1.100:8000/
ProxyPassReverse / http://192.168.1.100:8000/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>

<VirtualHost *:80>
ServerName sub.example.com
ProxyPass / http://192.168.1.100:8001/
ProxyPassReverse / http://192.168.1.100:8001/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>


Restart apache



On each Worpdress Site:



The last thing to do is to change the 'site_url' and 'home' settings to point to the host machine's ip address (192.168.1.100 here).
This can be done by 2 ways:

Either by going to the wordpress database, table wp_options and modifying:
site_url and home to http://192.168.1.100:8000 for www.example.com and example.com; and
site_url and home to http://192.168.1.100:8001 for sub.example.com



Or by logging into your Wordpress Dashboard (/wp-admin) then going to Settings and modifying:
WordPress Address (URL) and Site Address (URL) to http://192.168.1.100:8000 for www.example.com and example.com; and
WordPress Address (URL) and Site Address (URL) to http://192.168.1.100:8001 for sub.example.com



You shouldn't need to restart the Wordpress containers, but if you get any errors, restart them and check again.






share|improve this answer
































    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You can try checking the logs located in var/log/httpd(You can also try sudo locate access.log) for the actual error that is happening.



    The one thing you are missing is ProxyPassReverse which will rewrite the URL if your website is redirecting. With it your configuration will look something like this



    <VirtualHost *:80>
    ServerName www.example.com
    ProxyPass / http://localhost:8000/
    ProxyPassReverse / http://localhost:8000/
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    </VirtualHost>

    <VirtualHost *:80>
    ServerName sub.example.com
    ProxyPass / http://localhost:8001/
    ProxyPassReverse / http://localhost:8001/
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    </VirtualHost>





    share|improve this answer



















    • 1





      I added the ProxyPassReverse, restarted apache, same error, checked the logs and realised that my apache is in a docker container also, so localhost defines the apache docker localhost and not the host machine's localhost... I changed localhost:8001 to host_machine_ip:8001 then it seemed to work. I need to do more tests as a new issue has appeared,,, thank you for the help.

      – Fab Sanchez
      Nov 15 '18 at 9:18
















    0














    You can try checking the logs located in var/log/httpd(You can also try sudo locate access.log) for the actual error that is happening.



    The one thing you are missing is ProxyPassReverse which will rewrite the URL if your website is redirecting. With it your configuration will look something like this



    <VirtualHost *:80>
    ServerName www.example.com
    ProxyPass / http://localhost:8000/
    ProxyPassReverse / http://localhost:8000/
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    </VirtualHost>

    <VirtualHost *:80>
    ServerName sub.example.com
    ProxyPass / http://localhost:8001/
    ProxyPassReverse / http://localhost:8001/
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    </VirtualHost>





    share|improve this answer



















    • 1





      I added the ProxyPassReverse, restarted apache, same error, checked the logs and realised that my apache is in a docker container also, so localhost defines the apache docker localhost and not the host machine's localhost... I changed localhost:8001 to host_machine_ip:8001 then it seemed to work. I need to do more tests as a new issue has appeared,,, thank you for the help.

      – Fab Sanchez
      Nov 15 '18 at 9:18














    0












    0








    0







    You can try checking the logs located in var/log/httpd(You can also try sudo locate access.log) for the actual error that is happening.



    The one thing you are missing is ProxyPassReverse which will rewrite the URL if your website is redirecting. With it your configuration will look something like this



    <VirtualHost *:80>
    ServerName www.example.com
    ProxyPass / http://localhost:8000/
    ProxyPassReverse / http://localhost:8000/
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    </VirtualHost>

    <VirtualHost *:80>
    ServerName sub.example.com
    ProxyPass / http://localhost:8001/
    ProxyPassReverse / http://localhost:8001/
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    </VirtualHost>





    share|improve this answer













    You can try checking the logs located in var/log/httpd(You can also try sudo locate access.log) for the actual error that is happening.



    The one thing you are missing is ProxyPassReverse which will rewrite the URL if your website is redirecting. With it your configuration will look something like this



    <VirtualHost *:80>
    ServerName www.example.com
    ProxyPass / http://localhost:8000/
    ProxyPassReverse / http://localhost:8000/
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    </VirtualHost>

    <VirtualHost *:80>
    ServerName sub.example.com
    ProxyPass / http://localhost:8001/
    ProxyPassReverse / http://localhost:8001/
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    </VirtualHost>






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 14 '18 at 15:06









    ShivaShiva

    5,05332749




    5,05332749








    • 1





      I added the ProxyPassReverse, restarted apache, same error, checked the logs and realised that my apache is in a docker container also, so localhost defines the apache docker localhost and not the host machine's localhost... I changed localhost:8001 to host_machine_ip:8001 then it seemed to work. I need to do more tests as a new issue has appeared,,, thank you for the help.

      – Fab Sanchez
      Nov 15 '18 at 9:18














    • 1





      I added the ProxyPassReverse, restarted apache, same error, checked the logs and realised that my apache is in a docker container also, so localhost defines the apache docker localhost and not the host machine's localhost... I changed localhost:8001 to host_machine_ip:8001 then it seemed to work. I need to do more tests as a new issue has appeared,,, thank you for the help.

      – Fab Sanchez
      Nov 15 '18 at 9:18








    1




    1





    I added the ProxyPassReverse, restarted apache, same error, checked the logs and realised that my apache is in a docker container also, so localhost defines the apache docker localhost and not the host machine's localhost... I changed localhost:8001 to host_machine_ip:8001 then it seemed to work. I need to do more tests as a new issue has appeared,,, thank you for the help.

    – Fab Sanchez
    Nov 15 '18 at 9:18





    I added the ProxyPassReverse, restarted apache, same error, checked the logs and realised that my apache is in a docker container also, so localhost defines the apache docker localhost and not the host machine's localhost... I changed localhost:8001 to host_machine_ip:8001 then it seemed to work. I need to do more tests as a new issue has appeared,,, thank you for the help.

    – Fab Sanchez
    Nov 15 '18 at 9:18













    0














    I understand that my question may be off-topic here, but since I managed to solve my problem, I hope you will allow my answer to remain here so that it may help someone else.



    I failed to mention that the apache server was running in its own Docker container.



    This is what I did to solve the problem:



    In the host machine:



    Include www.example.com, example.com and sub.example.com in the hosts file:



    127.0.0.1       localhost  
    127.0.0.1 example.com www.example.com sub.example.com


    In the apache docker container:



    Since apache is running in its own docker container, localhost:8000 points to apache docker container's localhost which is incorrect here.

    It needs to point to the host machine's ip address, which in my case is 192.168.1.100.



    <VirtualHost *:80>
    ServerName www.example.com
    ProxyPass / http://192.168.1.100:8000/
    ProxyPassReverse / http://192.168.1.100:8000/
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    </VirtualHost>

    <VirtualHost *:80>
    ServerName sub.example.com
    ProxyPass / http://192.168.1.100:8001/
    ProxyPassReverse / http://192.168.1.100:8001/
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    </VirtualHost>


    Restart apache



    On each Worpdress Site:



    The last thing to do is to change the 'site_url' and 'home' settings to point to the host machine's ip address (192.168.1.100 here).
    This can be done by 2 ways:

    Either by going to the wordpress database, table wp_options and modifying:
    site_url and home to http://192.168.1.100:8000 for www.example.com and example.com; and
    site_url and home to http://192.168.1.100:8001 for sub.example.com



    Or by logging into your Wordpress Dashboard (/wp-admin) then going to Settings and modifying:
    WordPress Address (URL) and Site Address (URL) to http://192.168.1.100:8000 for www.example.com and example.com; and
    WordPress Address (URL) and Site Address (URL) to http://192.168.1.100:8001 for sub.example.com



    You shouldn't need to restart the Wordpress containers, but if you get any errors, restart them and check again.






    share|improve this answer






























      0














      I understand that my question may be off-topic here, but since I managed to solve my problem, I hope you will allow my answer to remain here so that it may help someone else.



      I failed to mention that the apache server was running in its own Docker container.



      This is what I did to solve the problem:



      In the host machine:



      Include www.example.com, example.com and sub.example.com in the hosts file:



      127.0.0.1       localhost  
      127.0.0.1 example.com www.example.com sub.example.com


      In the apache docker container:



      Since apache is running in its own docker container, localhost:8000 points to apache docker container's localhost which is incorrect here.

      It needs to point to the host machine's ip address, which in my case is 192.168.1.100.



      <VirtualHost *:80>
      ServerName www.example.com
      ProxyPass / http://192.168.1.100:8000/
      ProxyPassReverse / http://192.168.1.100:8000/
      <Proxy *>
      Order deny,allow
      Allow from all
      </Proxy>
      </VirtualHost>

      <VirtualHost *:80>
      ServerName sub.example.com
      ProxyPass / http://192.168.1.100:8001/
      ProxyPassReverse / http://192.168.1.100:8001/
      <Proxy *>
      Order deny,allow
      Allow from all
      </Proxy>
      </VirtualHost>


      Restart apache



      On each Worpdress Site:



      The last thing to do is to change the 'site_url' and 'home' settings to point to the host machine's ip address (192.168.1.100 here).
      This can be done by 2 ways:

      Either by going to the wordpress database, table wp_options and modifying:
      site_url and home to http://192.168.1.100:8000 for www.example.com and example.com; and
      site_url and home to http://192.168.1.100:8001 for sub.example.com



      Or by logging into your Wordpress Dashboard (/wp-admin) then going to Settings and modifying:
      WordPress Address (URL) and Site Address (URL) to http://192.168.1.100:8000 for www.example.com and example.com; and
      WordPress Address (URL) and Site Address (URL) to http://192.168.1.100:8001 for sub.example.com



      You shouldn't need to restart the Wordpress containers, but if you get any errors, restart them and check again.






      share|improve this answer




























        0












        0








        0







        I understand that my question may be off-topic here, but since I managed to solve my problem, I hope you will allow my answer to remain here so that it may help someone else.



        I failed to mention that the apache server was running in its own Docker container.



        This is what I did to solve the problem:



        In the host machine:



        Include www.example.com, example.com and sub.example.com in the hosts file:



        127.0.0.1       localhost  
        127.0.0.1 example.com www.example.com sub.example.com


        In the apache docker container:



        Since apache is running in its own docker container, localhost:8000 points to apache docker container's localhost which is incorrect here.

        It needs to point to the host machine's ip address, which in my case is 192.168.1.100.



        <VirtualHost *:80>
        ServerName www.example.com
        ProxyPass / http://192.168.1.100:8000/
        ProxyPassReverse / http://192.168.1.100:8000/
        <Proxy *>
        Order deny,allow
        Allow from all
        </Proxy>
        </VirtualHost>

        <VirtualHost *:80>
        ServerName sub.example.com
        ProxyPass / http://192.168.1.100:8001/
        ProxyPassReverse / http://192.168.1.100:8001/
        <Proxy *>
        Order deny,allow
        Allow from all
        </Proxy>
        </VirtualHost>


        Restart apache



        On each Worpdress Site:



        The last thing to do is to change the 'site_url' and 'home' settings to point to the host machine's ip address (192.168.1.100 here).
        This can be done by 2 ways:

        Either by going to the wordpress database, table wp_options and modifying:
        site_url and home to http://192.168.1.100:8000 for www.example.com and example.com; and
        site_url and home to http://192.168.1.100:8001 for sub.example.com



        Or by logging into your Wordpress Dashboard (/wp-admin) then going to Settings and modifying:
        WordPress Address (URL) and Site Address (URL) to http://192.168.1.100:8000 for www.example.com and example.com; and
        WordPress Address (URL) and Site Address (URL) to http://192.168.1.100:8001 for sub.example.com



        You shouldn't need to restart the Wordpress containers, but if you get any errors, restart them and check again.






        share|improve this answer















        I understand that my question may be off-topic here, but since I managed to solve my problem, I hope you will allow my answer to remain here so that it may help someone else.



        I failed to mention that the apache server was running in its own Docker container.



        This is what I did to solve the problem:



        In the host machine:



        Include www.example.com, example.com and sub.example.com in the hosts file:



        127.0.0.1       localhost  
        127.0.0.1 example.com www.example.com sub.example.com


        In the apache docker container:



        Since apache is running in its own docker container, localhost:8000 points to apache docker container's localhost which is incorrect here.

        It needs to point to the host machine's ip address, which in my case is 192.168.1.100.



        <VirtualHost *:80>
        ServerName www.example.com
        ProxyPass / http://192.168.1.100:8000/
        ProxyPassReverse / http://192.168.1.100:8000/
        <Proxy *>
        Order deny,allow
        Allow from all
        </Proxy>
        </VirtualHost>

        <VirtualHost *:80>
        ServerName sub.example.com
        ProxyPass / http://192.168.1.100:8001/
        ProxyPassReverse / http://192.168.1.100:8001/
        <Proxy *>
        Order deny,allow
        Allow from all
        </Proxy>
        </VirtualHost>


        Restart apache



        On each Worpdress Site:



        The last thing to do is to change the 'site_url' and 'home' settings to point to the host machine's ip address (192.168.1.100 here).
        This can be done by 2 ways:

        Either by going to the wordpress database, table wp_options and modifying:
        site_url and home to http://192.168.1.100:8000 for www.example.com and example.com; and
        site_url and home to http://192.168.1.100:8001 for sub.example.com



        Or by logging into your Wordpress Dashboard (/wp-admin) then going to Settings and modifying:
        WordPress Address (URL) and Site Address (URL) to http://192.168.1.100:8000 for www.example.com and example.com; and
        WordPress Address (URL) and Site Address (URL) to http://192.168.1.100:8001 for sub.example.com



        You shouldn't need to restart the Wordpress containers, but if you get any errors, restart them and check again.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 16 '18 at 13:48

























        answered Nov 15 '18 at 9:27









        Fab SanchezFab Sanchez

        14




        14