I have ubuntu 16.04 with nginx and apache2. There are 2 DNS A records pointed to this machine:
- app1.mydomain.com
- app2.mydomain.com
I need app1.mydomain.com to be resolved by apache and app2.mydomain.com to be resolved by nginx. Both on port 80. Is it possible?
moreover apache needs to handle 2 different applications (site1 and site2).
I would like:
- app1.mydomain.com/site1 - to be resolved by apache and run application site1
- app1.mydomain.com/site2 - to be resolved by apache and fire application site2
- app2.mydomain.com - to serve ghost application with nginx
This is my Apache configuration:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName app1.mydomain.com
ServerAlias www.app1.mydomain.com
ErrorLog /var/www/site1/logs/error.log
CustomLog /var/www/site1/logs/access.log combined
WSGIScriptAlias /api /var/www/site1/application/index.py/
Alias /static /var/www/site1/application/static
<Directory /var/www/site1/application>
Order deny,allow
Allow from all
</Directory>
AddType text/html .py
ErrorLog /var/www/site2/logs/error.log
CustomLog /var/www/site2/logs/access.log combined
WSGIScriptAlias /site2 /var/www/site2/index.py/
Alias /site2/uploads /var/sftp/site2/uploads/
<Directory /var/www/site2/>
Order deny,allow
Allow from all
</Directory>
This is my NGINX config file:
server {
listen 8080;
listen [::]:8080;
server_name app2.mydomain.com;
root /var/www/ghost/system/nginx-root;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:2368;
}
location ~ /.well-known {
allow all;
}
client_max_body_size 50m;
}