IIS 7.5 ARR/URL ReWrite2 ReversProxy to Apache on Virtual Machine - asp.net

Here's the scenario.
Server is Win2k8, running IIS 7.5. I have ARR and URL Rewrite2 installed.
I have a virtual box running the latest Ubuntu Server. Apache, mySQL, PHP are all installed.
I have IIS configured as a reverse proxy, and have setup a URL ReWrite as such:
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="false">
<match url="(.*)" />
<action type="Rewrite" url="http://192.168.1.17/{R:1}" />
</rule>
</rules>
</rewrite>
I have verified that http://dev.o7t.in correctly gets routed to the configured site in apache on the VM, however, http://wp.o7t.in gets directed to the same exact place. Here's the config from both sites in apache:
Dev:
# NameVirtualHost *:80
<VirtualHost *>
ServerName devo7tin
ServerAlias dev.o7t.in
ServerAdmin support#o7t.in
DocumentRoot /var/www/dev/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/dev/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
wp:
# NameVirtualHost *:80
<VirtualHost *>
ServerName wpo7tin
ServerAlias wp.o7t.in
ServerAdmin support#o7t.in
DocumentRoot /var/www/wordpress/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/wordpress/>
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
and NameVirtualHost is configured already in ports.conf
What I am noticing is the Host Header, always reverts to the IP address of the virtual machine (in this case 192.168.1.17), and completely ignores the requested host.
So.... how can I get around this, and pass my VM the correct HTTP_HOST header?

I was right. It was an IIS thing not sending the HTTP_HOST header. Of course, why would they post it anywhere, but apparently ARR by default disables, however, it can be enabled via:
appcmd.exe set config -section:system.webServer/proxy /preserveHostHeader:"True" /commit:apphost
Configured this, and it now works!

Related

I got server error when using Bitnami Wordpress

I manage 3 websites on one server instance. I set the Bitnami.conf like below
<VirtualHost *:80>
ServerName morethanair.com
ServerAlias morethanair.com
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
<Directory "/opt/bitnami/apps/wordpress/htdocs">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
# Bitnami applications installed with a prefix URL (default)
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>
<VirtualHost *:80>
ServerName microblog.morethanair.com
DocumentRoot "/opt/bitnami/apps/wordpress/microblog-wordpress/"
<Directory "/opt/bitnami/apps/wordpress/microblog-wordpress/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
# Bitnami applications installed with a prefix URL (default)
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>
<VirtualHost *:80>
ServerName photo.morethanair.com
DocumentRoot "/opt/bitnami/apps/wordpress/photo-wordpress/"
<Directory "/opt/bitnami/apps/wordpress/photo-wordpress/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
# Bitnami applications installed with a prefix URL (default)
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>
I can connect 2 sites with subdomain (photo.morethanair.com and microblog.morethanair.com), but the server error occurred when I try to connect morethanair.com.
When I type 'morethanair.com' in the browser, the URL changes to 'morethanair.com//' with double slash.
Any idea to resolve this?
I already tried to delete Wordpress and all plug-ins and reinstalled the latest Wordpress, but it didn't work.
Thank you.

DNS error - host not found after enabling site

I get the below error when I try and setup by wordpress site on Apache, beta.xxx.co.uk. Any ideas? I am expecting to see the wordpress setup wizard but just get an error.
I have:
setup my A record in my DNS under my domain (beta).
created my conf file under sites-available
sudo a2ensite beta.xxxx.co.uk.conf
​sudo service apache2 restart
Conf file:
<VirtualHost *:80>
ServerName beta.xxx.co.uk
DocumentRoot /var/www/beta.xxx.co.uk
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/beta.xxx.co.uk/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
Host Not Found
DNS error (the host name of the page you are looking for does not exist) or Server did not accept the connection.
Please check that the host name has been spelled correctly.
all I could find is:
<Directory /var/www/beta.xxx.co.uk/>
should propably be:
<Directory /var/www/beta.xxx.co.uk>
Port 80 & 443 is open?
Regards Tom

Apache configuration to serve 2 website and APIs under the same domain

I would like to configure Apache in order to have under the same domain:
a static website (it is a Single Page Application created with
create-react-app) deployed in /var/www/html/ui
a WordPress instance deployed in /var/www/wordpress/Commdev
some Node.js APIs running on http://localhost:3000/api
I would like to have the following URL mapping:
mydomain.com/ -> to the static website
mydomain.com/admin -> to the WordPress instance (mydomain.com/admin/wp-admin to the Admin Panel of WordPress )
mydomain.com/api -> proxy the Node.js APIs
This is my initial configuration
ServerName 127.0.0.1:80
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
<Location /api>
ProxyPass http://localhost:3000/api
ProxyPassReverse http://localhost:3000/api
</Location>
Alias /admin /var/www/wordpress/Commdev
<Directory /var/www/wordpress/Commdev>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Alias / /var/www/html/ui
<Directory /var/www/html/ui>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
How would you address the situation?
Many thanks in advance
This is the final configuration:
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot /var/www/html/ui
ProxyRequests Off
ProxyPreserveHost On
# ProxyVia Full
<Location /api>
ProxyPass http://localhost:3000/api
ProxyPassReverse http://localhost:3000/api
</Location>
<Location />
Options Indexes FollowSymLinks
#AllowOverride None
Order Allow,Deny
Allow from all
</Location>
Alias /admin /var/www/wordpress/Commdev
<Location /admin>
Options Indexes FollowSymLinks
#AllowOverride All
Order Allow,Deny
Allow from all
</Location>
</VirtualHost>

Can't get to subsites. Wildcard-subdomains probably misconfigured in Apache

I'm building a portal for the organization I'm working at.
The portal is a Wordpress site using Wampserver 2.5, intalled on a Win server 2008 R2.
It's working fine and accesible from other machines over the intranet, thanks to the helpful and patient RiggsFolly.
But now, I have changed it into a network of sites so that I can build sub-portals for the different departments in my organization.
During that change Wordpress gave this warning message: Warning! Wildcard DNS may not be configured correctly!
Wordpress has a page explaining how to configure wildcard subdomains on Apache - http://codex.wordpress.org/Configuring_Wildcard_Subdomains.
I tried following it but the explanation lacks details and I'm probably doing something wrong.
On the machine where the servers and site are installed, when I write http://hipo (hipo is the current site name) in the browser's address bar, I get to the site fine.
But when I write http://depa.hipo (depa is a subsite I created successfully), the address changes into http://www.depa.hipo/ and the browser says it didn't find a server at that address.
I have probably set the ServerAlias line wrong in httpd-vhosts.conf, and also I didn't add the line *.example.com A 192.0.43.10, or in my case *.hipo A <rightIP>, cause I wasn't sure where to add it in the file.
This is my httpd-vhosts.conf file. Your help is appreciated!
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/hipo"
ServerName hipo
<Directory "c:/wamp/www/hipo">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/hipo"
ServerName subsites.hipo
ServerAlias *.hipo
<Directory "c:/wamp/www/hipo">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp/www">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
This definition does not have a ServerAlias so try adding one like this:
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/hipo"
ServerName hipo
ServerAlias www.hipo
<Directory "c:/wamp/www/hipo">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

How to point URL path to a wordpress folder

I currently have two sites, hosted on the same server using Apache virtual hosts.
http://www.example.com -> /var/www/sites/mysite (path to main website)
http://blog.example.com -> /var/www/sites/blog (path to wordpress folder)
I need my blog to be accessible from www.example.com/blog
I cannot move the wordpress installation into a 'blog' subdirectory of the mysite folder.
Using the Apache Alias directive, I can do the following in the configuration for www.example.com:
Alias /blog /var/www/sites/blog
and access the blog via www.example.com/blog
However the following fails to work with a 404
www.example.com/blog/a-permalink-post-title
I have also tried using the following but the 404 still persists.
AliasMatch /blog/(.*)$ /var/www/sites/blog/$1
The current virtual host configuration looks like this:
<VirtualHost *:80>
ServerName www.example.com
Alias /blog /var/www/sites/blog
DocumentRoot /var/www/sites/mysite
<Directory /var/www/sites/mysite>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
and for blog.example.com
<VirtualHost *:80>
ServerName blog.example.com
DocumentRoot /var/www/sites/blog
<Directory /var/www/sites/blog>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Would greatly appreciate any help with this.

Resources