Score:0

setting sub domain variable in apache

mx flag

I have an issue trying to get the subdomain as a variable and use it somewhere in another part

what I'm trying to do is a proxy configuration that allow me to connect between

aaa.example-example.com will show me example.com/aaa

and

bbb.example-example.com will show me example.com/bbb

my code :

 <IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName wildcard.example.com
    ServerAlias *.example.com
    ServerAdmin webmaster@localhost
    ProxyRequests Off
    
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
    
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

# the pattern of my website look like example-example.com 
    SetEnvIf Host "^([^.]*).example-example.come$" SUBDOMAIN=$1 

    SSLProxyEngine on
    ProxyPass / https://example1.com/%{ENV:SUBDOMAIN}
    ProxyPassReverse / https://example1.com

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/example.com-0001/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com-0001/privkey.pem
</VirtualHost>
</IfModule>

so SetEnvIf is not working and always printing %{ENV:SUBDOMAIN} instead of the actual subdomain

I have the exact problem explained in

https://stackoverflow.com/questions/36199764/setting-the-subdomain-as-a-variable-in-apache-config-to-be-used-in-the-same-conf

but I already have the same solution and it didn't work

I'm using Apache/2.4.29 (Ubuntu) I'm happy with any solution to the variable in the ProxyPass part.

thanks

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.