Custom HTTPD Config and DOCROOT based on port?

phonkala

New member
Joined
Oct 23, 2019
Messages
2
Hello there!

Is it possible, with the DA Custom HTTPD Configuration, to define separate document roots for different ports? The current situation is:
- I'm trying to set up dev.mydomain.com (added via domain administration as domain, not subdomain - if that makes any difference)
- I've got "Force SSL with https redirect" ON
- What I am trying to achieve is that
1. when accessing dev.mydomain.com, contents from /home/myuser/dir01 is loaded (SSL)
2. when accessing dev.mydomain.com:8083, contents from /home/myuser/dir02 is loaded (SSL)

I am easily able to set up the first part with |?DOCROOT=/home/myuser/dir01| in the Custom HTTPD Configuration, but have no clue how to do the second part (with the port specified). Tried to search the web for some answers but so far haven't found anything that works. Is there some token that I could use in the Custom HTTPD Configuration to check port? Or can this even work as the SSL uses port 443 anyways (as far as I know)?

I'm really unexperienced with this kind of configurations, any help will be greatly appreciated!

P.S. If it's not possible to get this working with separate port, would it be possible to do it with subfolder / url path? As in, dev.mydomain.com/mypath would load contents from /home/myuser/dir02 (symlinks propably work here but I would rather set this up admin level)? I believe something similar could be achieved with subdomains and the SUB token, but subdomains are not something I can use in this case. I also wouldn't want to modify the actual httpd configs in system if it is in any way possible to achieve this via Custom HTTPD Configuration.
 
Solved!

Finally managed to solve this via trial and error! :) Just pasting the solution here in case someone ever needs something like this.

So as said in original post, changing the default DOCROOT is easy, just paste in that |?DOCROOT=/home/myuser/dir01| and all works right away for that part.

Making that additional port work as desired needed bit more setting up but wasn't too hard after all. What I did was:

- First edited /etc/httpd/conf/extra/httpd-ssl.conf and added new Listen row to make server listen to the additional port (for example "Listen 8083" - I actually decided to use 8443 after all)
- Obviously opened that port in firewall too
- Opened the loaded httpd.conf via DA
- Searched the config for <VirtualHost x.x.x.x.:443> element that had ServerAlias match my domain (dev.mydomain.com) and that was using port 443 (SSL) and copied the whole thing to text editor
- Modified the port to :8443
- Modified all the paths inside the VirtualHost element to match the new directory (/home/myuser/dir01)
- Pasted the modified <VirtualHost> config to "CUSTOM1" field in the Custom HTTPD Configuration (only the CUSTOM1 field allowed <VirtualHost> element to be pasted in)
- Saved changes and restarted httpd
- It works! Opening domain dev.mydomain.com "normally" without port now loads content from /home/myuser/dir01 and dev.mydomain.com:8443 loads content from /home/myuser/dir02
 
Back
Top