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

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>

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.

Create website conf with 2 virtual hosts

I want to know if it's possible to have one apache website conf file with two vhost inside ?
More clearly :
For now if I access my website like this : XX.XX.XXX.XX I reach my wordpress folder.
Now, I want to access another folder like this : XX.XX.XXX.XX/interface
Is it possible to do it in the same conf file ?
Here is mine actually :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/wordpress/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/wordpress/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
Thanks in advance

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.

IIS 7.5 ARR/URL ReWrite2 ReversProxy to Apache on Virtual Machine

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!

mod_mono on windows

I am trying mod_mono on apache 2.2.x running on a win7 box – followed the steps described here.
The module loads Ok, but I can't run my ASP.net application (404). Does anybody have any suggestions or an example configuration that works? Thanks.
My working config:
<VirtualHost *:80>
ServerAlias localhost
DocumentRoot "c:\web\mysite"
MonoServerPath mysite "c:\mono\usr\bin\mod-mono-server2.exe"
MonoApplications mysite "/:c:\web\mysite"
<Directory "c:\web\mysite">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
MonoSetServerAlias mysite
SetHandler mono
DirectoryIndex default.aspx index.html
</Directory>
</VirtualHost>
I found a good tutorial for you.
Example mono configuration:
MonoServerPath default /usr/bin/mod-mono_server2
Alias [D] “[P]”
AddMonoApplications default “[D]:[P]”
<Location [D]>
SetHandler mono
</Location>
Another example:
MonoServerPath default /usr/bin/mod-mono_server2
Alias /MySite “/srv/www/htdocs/MySite”
AddMonoApplications default “/MySite:/srv/www/htdocs/MySite”
<Location /MySite>
SetHandler mono
</Location>

Resources