Access the same domain with different folders from the Internet
Posted by: sylarlocke (---.ipcom.comunitel.net)
Date: September 19, 2023 11:07AM

Access the same domain with different folders from the Internet

Hello,

I would like to know if there is the possibility of having a domain, which I have associated with my public IP with ddns, configured on my router.

Currently I have configured FCGI locally, so that I do have:
C:\wamp\www\project1
This go to version 7.4

Yes I have:
C:\wamp\www\project2
It will go to default version 8.2

So I have it configured like this:

On host:
::1 localhost
127.0.0.1 localhost
192.168.2.5 localhost
192.168.2.5 mydomain.ddns.net
192.168.2.5 mydomain.ddns.net:8081
192.168.2.5 project1.local
192.168.2.5 project2.local

In httpd.conf:
Defines MYPORT8081 8081
Listen 0.0.0.0:80
Listen [::0]:80
Listen 0.0.0.0:${MYPORT8081}
Listen [::0]:${MYPORT8081}

And in httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp/www
    <Directory "c:/wamp/www/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
ServerName mydomain.ddns.net
DocumentRoot "c:/wamp/www/project1"
    <Directory "c:/wamp/www/project1/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
   <IfModule fcgid_module>
       Defines FCGIPHPVERSION "7.4.22"
       FcgidInitialEnv PHPRC ${PHPROOT}${FCGIPHPVERSION}
      <Files ~ "\.php$">
           Options +Indexes +Includes +FollowSymLinks +MultiViews +ExecCGI
           AddHandler fcgid-script .php
           FcgidWrapper "${PHPROOT}${FCGIPHPVERSION}/php-cgi.exe" .php
     </Files>
   </IfModule>
</VirtualHost>
#

<VirtualHost *:8081>
ServerName mydomain.ddns.net
DocumentRoot "c:/wamp/www/project2/public"
    <Directory "c:/wamp/www/project2/public/">
        Options +Indexes +Includes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
As you can see in Servername, I would like to have the same domain that points to both sites, but when I type in the browser from the internet I can access:
- project1: mydomain.ddns.net
- project2: mydomain.ddns.net:8081

****Initially locally I have ServerName***
project1: project1.local
project2: project2.local

With the configuration that I have set, if I try to access mydomain.ddns.net it does access project1 but if I try to access mydomain.ddns.net:8081 it gives me an error


If I leave it as I have it locally and I want to access it from the internet, I would have to put it like this:
midomino.ddns.net/project1/

If you access it but project1 would have the default php configuration 8.2, so the FCGI is lost and of course my idea is to be able to access it from the internet but each project with its php version as I have it locally, but I have not been able to do it.

I have several questions:

Can you connect access from the Internet with a single domain to different folders by accessing through different ports (the example I have given in this post)?

If this is not possible, could you configure an https with svirtualhost that points to project1 (for example https) and project2 to (http)?

Would I have to contract a domain, for example mydomain.com, to be able to create subdomains and in turn be able to link with ddns to my public IP?

I have updated to the latest version of
wamp 3.3.1
Apache 2.4.57.4
php 8.2.10 by default
php 7.4.22


Sorry for the blurb, I've been using wamp for many years and I like it, but being able to configure several projects from the internet is important.

Thank you so much.



Edited 1 time(s). Last edit at 09/19/2023 01:01PM by RiggsFolly.

Options: ReplyQuote
Re: Access the same domain with different folders from the Internet
Posted by: RiggsFolly (Moderator)
Date: September 19, 2023 01:10PM

First, this line in the HOSTS file is not valid. The port number is not a valid entry and is ignored even if it does not cause errors

192.168.2.5 mydomain.ddns.net:8081


Secondly, you cannot have2 virtual hosts with the same ServerName by virtue of the way Apache searches the Virtual Host list to see if it can find a matching Servername. In short it will finf the first one and never the second.

See The Apache documentation for a better description

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Access the same domain with different folders from the Internet
Posted by: Otomatic (Moderator)
Date: September 19, 2023 01:12PM

Hi,

Ask mydomain.ddns.net if you can add a port number and how!

On the other hand, for the VirtualHost that doesn't use port 80 but 8081, the line:
<VirtualHost *:8081>
should be :
<VirtualHost *:${MYPORT8081}>

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Access the same domain with different folders from the Internet
Posted by: sylarlocke (---.ipcom.comunitel.net)
Date: September 19, 2023 02:59PM

Hello,

Thanks for your help.

But he had already indicated the errors in the post with the "duplicate ServerName" error, but what he was asking were several things, including:

Can you connect access from the Internet with a single domain to different folders by accessing through different ports (the example I have given in this post)?

Would I have to contract a domain, for example mydomain.com, to be able to create subdomains and at the same time be able to link with ddns to my public IP?

Is there a way to access different folders with a single domain?

By the way, I had also tried this and both work:
VirtualHost *:8081
VirtualHost *:$MYPORT8081.

But it does not work for the objective I want, to be able to access each project (folders) from the internet in such a way that each project has its associated PHP version

Right now if I put:
mydomain.ddns.net/project1
I can access it but obviously it is not taking the FCGI assigned in virtualhost so the php version will be the default 8.2, but project1 is assigned 7.4

Greetings

Options: ReplyQuote
Re: Access the same domain with different folders from the Internet
Posted by: Otomatic (Moderator)
Date: September 19, 2023 03:50PM

Hi,

> By the way, I had also tried this and both work:
> VirtualHost *:8081
> VirtualHost *:$MYPORT8081.

Well, maybe! But you need to be consistent, because 8081 and ${MYPORT8081} are two totally different things, even if the result seems to be the same, and IT won't recognize them as identical.
You've declared an additional Apache listen port via Right-Click ->Tools -> Add a listen port for Apache which has created the Apache variable ${MYPORT8081} and it's this variable that should be used.

And, as RiggsFolly wrote:
« you cannot have2 virtual hosts with the same ServerName by virtue of the way Apache searches the Virtual Host list to see if it can find a matching Servername. In short it will finf the first one and never the second. »

I'm afraid this isn't possible from the outside using mydomain.ddns.net.

It might be possible if you had a fixed and invariable IPv4.

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Access the same domain with different folders from the Internet
Posted by: sylarlocke (---.ipcom.comunitel.net)
Date: September 20, 2023 10:25AM

Hello,

Thanks for the clarification of the ports. I had tried both configurations but failed, because the only idea of using two different ports is to be able to access each folder through a different port, but if it cannot be put in the ServerName this idea does not serve what I want.

So, following my main question:
Is there no way to access different virtualhosts with a public IP assigned to ddns?

I have thought that it could be to hire a domain and have it linked to my IP and then put subdomains to each servername, I understand that this would be possible, right?

That is, now I have mydomain.ddns.net, it is a subdomain, with the disadvantages of a subdomain.

But I could contract a domain, mydomain.net and have it do the same ddns operation with my public IP and then give each project a subdomain.

project1.mydomain.net
project2.mydomain.net

And these are the ServerName and can be accessed from the internet and each one with its version of php.

This would be possible, right?

I would like to know all the options I have to achieve my goal.

That is to say, enter each folder (projects) from the Internet and ensure that they have their PHP versions, which is what I have right now locally, but it does not work on the Internet.

Thank you for your help and patience.



Edited 1 time(s). Last edit at 09/20/2023 10:26AM by sylarlocke.

Options: ReplyQuote
Re: Access the same domain with different folders from the Internet
Posted by: Otomatic (Moderator)
Date: September 20, 2023 11:15AM

Hi,

May be :

mydomain1.ddns.net

mudomain2.ddns.net

---------------------------------------------------------------
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons

Options: ReplyQuote
Re: Access the same domain with different folders from the Internet
Posted by: sylarlocke (---.ipcom.comunitel.net)
Date: September 20, 2023 11:43AM

Hello, in principle no.

Because I have contracted with noip the domain with the name:

mydomain.ddns.net

And he is the one that points on my router to my dynamic public IP.

Options: ReplyQuote
Re: Access the same domain with different folders from the Internet
Posted by: RiggsFolly (Moderator)
Date: September 20, 2023 12:59PM

You create 2 domains in your DDNS account both pointing to your IP.

Apache then looks at the domain name and tries to find it in the Virtual Hosts list.
Apache (if it finds the domain) then serves pages from the folder pointer to by the specific Virtual Host

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.3.4 64bit) Aestan Tray Menu 3.2.5.4
<Apache versions MULTIPE> <PHP versions MULTIPLE> <MySQL Versions MULTIPLE>
<MariaDB versions MULTIPLE> <phpMyAdmin versions MULTIPLE> <MySQL Workbench 8.0.23>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-



Edited 1 time(s). Last edit at 09/20/2023 02:11PM by RiggsFolly.

Options: ReplyQuote
Re: Access the same domain with different folders from the Internet
Posted by: sylarlocke (---.ipcom.comunitel.net)
Date: September 20, 2023 02:22PM

RiggsFolly Wrote:
-------------------------------------------------------
> You create 2 domains in your DDNS account both
> pointing to your IP.
>
> Apache then looks at the domain name and tries to
> find it in the Virtual Hosts list.
> Apache (if it finds the domain) then serves pages
> from the folder pointer to by the specific Virtual
> Host

Excellent, I have created two domains in the provider and I have pointed them to each folder and they have worked, I thank you very much for the help, it has been magnificent.

Greetings

Options: ReplyQuote


Sorry, only registered users may post in this forum.