Configuration apache with webroot and subdomains


#1

I have this configuration of virtualhost.

<VirtualHost *:80>
ServerName example.com
ServerAlias example.com subdomain1.example.com subdomain2.example.com

RewriteEngine on
RewriteRule		^/		-			[E=IP:%{REMOTE_ADDR}]
RequestHeader set       X_REMOTE_ADDR   %{IP}e


RewriteCond		%{HTTP_HOST}	www.ecample.com
RewriteRule		^/(.*)$		http://example.com/$1	[R=301,L]

RewriteCond		%{HTTP_HOST}	subdomain1.ecample.com
RewriteRule		^/		http://web-example:9020/subdomain1	[P]



RewriteCond		%{HTTP_HOST}	subdomain2.ecample.com
RewriteRule		^/		http://web-example:9020/subdomain2	[P]


ProxyPass		/		http://web-example:9020/ retry=1
ProxyPassReverse	/		http://web-example:9020/


ErrorLog		log/example-web-error_log
CustomLog		log/example-web-access_log combined

and for server listen on port 9020 have rule:

RewriteRule ^.well-known/ - [L,QSA]

I need help with configuration apache for webroot on subdomain. When I connect to example.com/well-known/… without problem. Only with subdomain. I dont know how make rewriterule for subdomain.


#2

Hi,

why you set X_REMOTE_ADDR as Header? In the backend you can use X-Forwarded-For to get the IP address. :see_no_evil:

Is web-example:9020 on the same apache webserver?
How does the virtualhost configuration of that host looks then? Is the DocumentRoot on the same directory?


#3

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.