0

Currently, we are having two webservers, the first one is directly handling request from domain1.com. I'm trying to deploy another webserver in which it will handle request from sub.domain2.com. Because there is no DNS server within our network, so I have to put the first webserver to handle all the request and forward it to the appropriate webserver (i.e. the second webserver). The second webserver will host wordpress and will be install on a non-root path of the webserver i.e. /wordpress and there will SSL certificate install as well. I have been trying to get it working but without any success, my current configuration as below:

<VirtualHost *:80>
    ServerName www.domain1.com
    DocumentRoot "D:/Apache2.2/htdocs"
    <Directory "D:/Apache2.2/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog "logs/www.domain1.com -error.log"
    CustomLog "logs/www.domain1.com-access.log" common
    ResinConfigServer 10.0.xx.1 6800
    <Location />
    SetHandler caucho-request
    </Location>
</VirtualHost>

<VirtualHost *:80>
ServerName sub.domain2.com
Redirect / https://sub.domain2.com/
</VirtualHost>

<VirtualHost *:443>
ServerName sub.domain2.com
ProxyRequests Off
<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>
SSLProxyEngine On
SSLProxyCheckPeerCN on
SSLProxyCheckPeerExpire on
SSLEngine on
SSLCertificateFile "D:\Apache2.2\ssl.pem"
SSLCertificateKeyFile "D:\Apache2.2\ssl.key"
SSLCACertificateFile "D:\Apache2.2\ssl.crt"

ProxyPreserveHost on

ProxyPass /wordpress https://10.0.xx.2:443/wordpress
ProxyPassReverse /wordpress https:// 10.0.xx.2:443/wordpress


ProxyPass / https://10.0.xx.2:443/wordpress
ProxyPassReverse / https://10.0.xx.2:443/wordpress

<Location />
    Order allow,deny
    Allow from all
</Location>
</VirtualHost>

If i tried to put the configuration as below, it worked, but it redirect the link to 10.0.xx.2 instead of sub.domain2.com

<VirtualHost *:80>
    ServerName sub.domain2.com
    DocumentRoot "D:/Apache2.2/htdocs"
    <Directory "D:/Apache2.2/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog "logs/sub.domain2.com-error.log"
    CustomLog "logs/sub.domain2.com-access.log" common
    ProxyPass / http://10.0.xx.2/wordpress/
</VirtualHost>

Wordpress .htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(sub.)?domain2.com$
RewriteCond %{REQUEST_URI} !^/wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /my_subdir/$1
RewriteCond %{HTTP_HOST} ^(sub.)?domain.com$
RewriteRule ^(/)?$ wordpress/index.php [L] 
</IfModule>
  • Please rewrite this in a way that can be followed - its so hard to understand I gave up after reading it twice.. Also, this belongs in a different SE - maybe webmasters.she or possibly server fault.se – davidgo Mar 30 '20 at 09:37
  • @davidgo i have rewrite the questions, i have been up for 24h straight just to figure out what a mess the other guys have left to me. many thanks – Long H Pham Mar 30 '20 at 12:04

0 Answers0