nginx and apache2 on same server
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
1
down vote
favorite
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 admin@mydomain.com
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;
16.04 apache2 nginx reverse-proxy
add a comment |Â
up vote
1
down vote
favorite
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 admin@mydomain.com
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;
16.04 apache2 nginx reverse-proxy
2
Possible duplicate of How do I configure my DNS settings in Ubuntu server?
â Elder Geek
Apr 8 at 15:23
@ElderGeek It's not a duplicate of that. I don't believe it has anything to do with DNS even.
â vidarlo
Apr 8 at 16:39
@vidarlo your edit makes that clear. I hope that corresponds with the OP's intent.
â Elder Geek
Apr 8 at 20:01
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
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 admin@mydomain.com
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;
16.04 apache2 nginx reverse-proxy
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 admin@mydomain.com
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;
16.04 apache2 nginx reverse-proxy
16.04 apache2 nginx reverse-proxy
edited Apr 8 at 16:28
![](https://i.stack.imgur.com/AKwUL.png?s=32&g=1)
![](https://i.stack.imgur.com/AKwUL.png?s=32&g=1)
vidarlo
7,14342140
7,14342140
asked Apr 8 at 15:14
![](https://i.stack.imgur.com/f8YRQ.jpg?s=32&g=1)
![](https://i.stack.imgur.com/f8YRQ.jpg?s=32&g=1)
Student Michal Wloga
83
83
2
Possible duplicate of How do I configure my DNS settings in Ubuntu server?
â Elder Geek
Apr 8 at 15:23
@ElderGeek It's not a duplicate of that. I don't believe it has anything to do with DNS even.
â vidarlo
Apr 8 at 16:39
@vidarlo your edit makes that clear. I hope that corresponds with the OP's intent.
â Elder Geek
Apr 8 at 20:01
add a comment |Â
2
Possible duplicate of How do I configure my DNS settings in Ubuntu server?
â Elder Geek
Apr 8 at 15:23
@ElderGeek It's not a duplicate of that. I don't believe it has anything to do with DNS even.
â vidarlo
Apr 8 at 16:39
@vidarlo your edit makes that clear. I hope that corresponds with the OP's intent.
â Elder Geek
Apr 8 at 20:01
2
2
Possible duplicate of How do I configure my DNS settings in Ubuntu server?
â Elder Geek
Apr 8 at 15:23
Possible duplicate of How do I configure my DNS settings in Ubuntu server?
â Elder Geek
Apr 8 at 15:23
@ElderGeek It's not a duplicate of that. I don't believe it has anything to do with DNS even.
â vidarlo
Apr 8 at 16:39
@ElderGeek It's not a duplicate of that. I don't believe it has anything to do with DNS even.
â vidarlo
Apr 8 at 16:39
@vidarlo your edit makes that clear. I hope that corresponds with the OP's intent.
â Elder Geek
Apr 8 at 20:01
@vidarlo your edit makes that clear. I hope that corresponds with the OP's intent.
â Elder Geek
Apr 8 at 20:01
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
First of all. Apache and Nginx are Web servers - not dns servers. They do not resolve anything. This question has nothing to do with DNS, but everything with how web servers handle requests.
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?
No, this is not possible. Two applications cannot listen to the same port. You can solve this in two ways:
- Have Apache listen on port 80, and proxy requests for app2.mydomain.com to nginx, listening on a different port, and serving app1.mydomain.com straight.
- Opposite. Have nginx proxy for Apache.
Or - make both hosted by the same webserver. Apache and nginx are in many instances interchangeable on the technical level, so from the applications perspective it should not really matter. Management-wise they're rather different.
I note that you run nginx on port 8080, so I assume you want to use apache as a proxy. Then create a new Virtual Host for apache, e.g. /etc/apache2-sites-available/app2.mydomain.com.conf
:
<VirtualHost *:80>
DocumentRoot "/var/www"
ErrorLog "logs/app2-error_log"
CustomLog "logs/app2-access_log" common
ServerName app2.mydomain.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
Proxypass / http://localhost:8080/
</VirtualHost>
Then run sudo a2enmod proxy_http; sudo a2ensite app2.mydomain.com; sudo service apache2 reload
.
This will enable mod_proxy, mod_proxy_http and make apache forward any requests for the VirtualHost app2.mydomain.com to nginx, which according to your config is running on port 8080.
I've not tested this config, so some tweaking may be needed.
As a sidenote: why do you need nginx? According to the nginx setup it just proxies a request for some other webserver running on port 2368. You can proxy directly using apache...
mod_proxy-documentation may be handy in tweaking it.
From the user's message, it doesn't appear he's confusing the web server with his DNS server. It appears he's saying his DNS servers are already configured and pointing to the machine's IP.
â L. D. James
Apr 8 at 16:33
Yes, and this is what I expect in my answer. It also looks like he's using nginx to proxy some other application...
â vidarlo
Apr 8 at 16:38
Thank you. It was what I was looking for. I am still experiencing some problems. I set nginx proxy to apache and it does work with proxy_pass app1.mydomain.com:80; but it does not work with proxy_pass 127.0.0.1:80; - something in apache should be set up I guess...
â Student Michal Wloga
Apr 9 at 21:13
add a comment |Â
up vote
0
down vote
By the content of your question, you already have it worked out, except that you can only access one application per port #. You can't run both Apache2 and Nginx on the same port. It's not possible.
Since you've mentioned you already have your DNS working and pointing to the correct machine (IP). You can reach your app1.mydomain.com
by the default (port 80
) with:
http://app1.mydomain.com
That's the same as
http://app1.mydomain.com:80
You will have to specify the port for your Nginx, which you have, by your configuration file, set for port 8080
.
Use this to access your site1:
http://app1.mydomain.com:8080
If you specify the wrong port, the default page will load regardless of the domainname used. For Apache, the default is the first virtual host, unless specified different.
But the goal is to connect app1.mydomain.com with Apache and app2.mydomain.com with Nginx. Both with port 80 so that user is not forced to specify port.
â Student Michal Wloga
Apr 8 at 16:26
In that case you can have one server refresh and reload to the alternate server.
â L. D. James
Apr 8 at 16:30
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
First of all. Apache and Nginx are Web servers - not dns servers. They do not resolve anything. This question has nothing to do with DNS, but everything with how web servers handle requests.
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?
No, this is not possible. Two applications cannot listen to the same port. You can solve this in two ways:
- Have Apache listen on port 80, and proxy requests for app2.mydomain.com to nginx, listening on a different port, and serving app1.mydomain.com straight.
- Opposite. Have nginx proxy for Apache.
Or - make both hosted by the same webserver. Apache and nginx are in many instances interchangeable on the technical level, so from the applications perspective it should not really matter. Management-wise they're rather different.
I note that you run nginx on port 8080, so I assume you want to use apache as a proxy. Then create a new Virtual Host for apache, e.g. /etc/apache2-sites-available/app2.mydomain.com.conf
:
<VirtualHost *:80>
DocumentRoot "/var/www"
ErrorLog "logs/app2-error_log"
CustomLog "logs/app2-access_log" common
ServerName app2.mydomain.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
Proxypass / http://localhost:8080/
</VirtualHost>
Then run sudo a2enmod proxy_http; sudo a2ensite app2.mydomain.com; sudo service apache2 reload
.
This will enable mod_proxy, mod_proxy_http and make apache forward any requests for the VirtualHost app2.mydomain.com to nginx, which according to your config is running on port 8080.
I've not tested this config, so some tweaking may be needed.
As a sidenote: why do you need nginx? According to the nginx setup it just proxies a request for some other webserver running on port 2368. You can proxy directly using apache...
mod_proxy-documentation may be handy in tweaking it.
From the user's message, it doesn't appear he's confusing the web server with his DNS server. It appears he's saying his DNS servers are already configured and pointing to the machine's IP.
â L. D. James
Apr 8 at 16:33
Yes, and this is what I expect in my answer. It also looks like he's using nginx to proxy some other application...
â vidarlo
Apr 8 at 16:38
Thank you. It was what I was looking for. I am still experiencing some problems. I set nginx proxy to apache and it does work with proxy_pass app1.mydomain.com:80; but it does not work with proxy_pass 127.0.0.1:80; - something in apache should be set up I guess...
â Student Michal Wloga
Apr 9 at 21:13
add a comment |Â
up vote
1
down vote
accepted
First of all. Apache and Nginx are Web servers - not dns servers. They do not resolve anything. This question has nothing to do with DNS, but everything with how web servers handle requests.
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?
No, this is not possible. Two applications cannot listen to the same port. You can solve this in two ways:
- Have Apache listen on port 80, and proxy requests for app2.mydomain.com to nginx, listening on a different port, and serving app1.mydomain.com straight.
- Opposite. Have nginx proxy for Apache.
Or - make both hosted by the same webserver. Apache and nginx are in many instances interchangeable on the technical level, so from the applications perspective it should not really matter. Management-wise they're rather different.
I note that you run nginx on port 8080, so I assume you want to use apache as a proxy. Then create a new Virtual Host for apache, e.g. /etc/apache2-sites-available/app2.mydomain.com.conf
:
<VirtualHost *:80>
DocumentRoot "/var/www"
ErrorLog "logs/app2-error_log"
CustomLog "logs/app2-access_log" common
ServerName app2.mydomain.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
Proxypass / http://localhost:8080/
</VirtualHost>
Then run sudo a2enmod proxy_http; sudo a2ensite app2.mydomain.com; sudo service apache2 reload
.
This will enable mod_proxy, mod_proxy_http and make apache forward any requests for the VirtualHost app2.mydomain.com to nginx, which according to your config is running on port 8080.
I've not tested this config, so some tweaking may be needed.
As a sidenote: why do you need nginx? According to the nginx setup it just proxies a request for some other webserver running on port 2368. You can proxy directly using apache...
mod_proxy-documentation may be handy in tweaking it.
From the user's message, it doesn't appear he's confusing the web server with his DNS server. It appears he's saying his DNS servers are already configured and pointing to the machine's IP.
â L. D. James
Apr 8 at 16:33
Yes, and this is what I expect in my answer. It also looks like he's using nginx to proxy some other application...
â vidarlo
Apr 8 at 16:38
Thank you. It was what I was looking for. I am still experiencing some problems. I set nginx proxy to apache and it does work with proxy_pass app1.mydomain.com:80; but it does not work with proxy_pass 127.0.0.1:80; - something in apache should be set up I guess...
â Student Michal Wloga
Apr 9 at 21:13
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
First of all. Apache and Nginx are Web servers - not dns servers. They do not resolve anything. This question has nothing to do with DNS, but everything with how web servers handle requests.
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?
No, this is not possible. Two applications cannot listen to the same port. You can solve this in two ways:
- Have Apache listen on port 80, and proxy requests for app2.mydomain.com to nginx, listening on a different port, and serving app1.mydomain.com straight.
- Opposite. Have nginx proxy for Apache.
Or - make both hosted by the same webserver. Apache and nginx are in many instances interchangeable on the technical level, so from the applications perspective it should not really matter. Management-wise they're rather different.
I note that you run nginx on port 8080, so I assume you want to use apache as a proxy. Then create a new Virtual Host for apache, e.g. /etc/apache2-sites-available/app2.mydomain.com.conf
:
<VirtualHost *:80>
DocumentRoot "/var/www"
ErrorLog "logs/app2-error_log"
CustomLog "logs/app2-access_log" common
ServerName app2.mydomain.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
Proxypass / http://localhost:8080/
</VirtualHost>
Then run sudo a2enmod proxy_http; sudo a2ensite app2.mydomain.com; sudo service apache2 reload
.
This will enable mod_proxy, mod_proxy_http and make apache forward any requests for the VirtualHost app2.mydomain.com to nginx, which according to your config is running on port 8080.
I've not tested this config, so some tweaking may be needed.
As a sidenote: why do you need nginx? According to the nginx setup it just proxies a request for some other webserver running on port 2368. You can proxy directly using apache...
mod_proxy-documentation may be handy in tweaking it.
First of all. Apache and Nginx are Web servers - not dns servers. They do not resolve anything. This question has nothing to do with DNS, but everything with how web servers handle requests.
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?
No, this is not possible. Two applications cannot listen to the same port. You can solve this in two ways:
- Have Apache listen on port 80, and proxy requests for app2.mydomain.com to nginx, listening on a different port, and serving app1.mydomain.com straight.
- Opposite. Have nginx proxy for Apache.
Or - make both hosted by the same webserver. Apache and nginx are in many instances interchangeable on the technical level, so from the applications perspective it should not really matter. Management-wise they're rather different.
I note that you run nginx on port 8080, so I assume you want to use apache as a proxy. Then create a new Virtual Host for apache, e.g. /etc/apache2-sites-available/app2.mydomain.com.conf
:
<VirtualHost *:80>
DocumentRoot "/var/www"
ErrorLog "logs/app2-error_log"
CustomLog "logs/app2-access_log" common
ServerName app2.mydomain.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
Proxypass / http://localhost:8080/
</VirtualHost>
Then run sudo a2enmod proxy_http; sudo a2ensite app2.mydomain.com; sudo service apache2 reload
.
This will enable mod_proxy, mod_proxy_http and make apache forward any requests for the VirtualHost app2.mydomain.com to nginx, which according to your config is running on port 8080.
I've not tested this config, so some tweaking may be needed.
As a sidenote: why do you need nginx? According to the nginx setup it just proxies a request for some other webserver running on port 2368. You can proxy directly using apache...
mod_proxy-documentation may be handy in tweaking it.
answered Apr 8 at 16:26
![](https://i.stack.imgur.com/AKwUL.png?s=32&g=1)
![](https://i.stack.imgur.com/AKwUL.png?s=32&g=1)
vidarlo
7,14342140
7,14342140
From the user's message, it doesn't appear he's confusing the web server with his DNS server. It appears he's saying his DNS servers are already configured and pointing to the machine's IP.
â L. D. James
Apr 8 at 16:33
Yes, and this is what I expect in my answer. It also looks like he's using nginx to proxy some other application...
â vidarlo
Apr 8 at 16:38
Thank you. It was what I was looking for. I am still experiencing some problems. I set nginx proxy to apache and it does work with proxy_pass app1.mydomain.com:80; but it does not work with proxy_pass 127.0.0.1:80; - something in apache should be set up I guess...
â Student Michal Wloga
Apr 9 at 21:13
add a comment |Â
From the user's message, it doesn't appear he's confusing the web server with his DNS server. It appears he's saying his DNS servers are already configured and pointing to the machine's IP.
â L. D. James
Apr 8 at 16:33
Yes, and this is what I expect in my answer. It also looks like he's using nginx to proxy some other application...
â vidarlo
Apr 8 at 16:38
Thank you. It was what I was looking for. I am still experiencing some problems. I set nginx proxy to apache and it does work with proxy_pass app1.mydomain.com:80; but it does not work with proxy_pass 127.0.0.1:80; - something in apache should be set up I guess...
â Student Michal Wloga
Apr 9 at 21:13
From the user's message, it doesn't appear he's confusing the web server with his DNS server. It appears he's saying his DNS servers are already configured and pointing to the machine's IP.
â L. D. James
Apr 8 at 16:33
From the user's message, it doesn't appear he's confusing the web server with his DNS server. It appears he's saying his DNS servers are already configured and pointing to the machine's IP.
â L. D. James
Apr 8 at 16:33
Yes, and this is what I expect in my answer. It also looks like he's using nginx to proxy some other application...
â vidarlo
Apr 8 at 16:38
Yes, and this is what I expect in my answer. It also looks like he's using nginx to proxy some other application...
â vidarlo
Apr 8 at 16:38
Thank you. It was what I was looking for. I am still experiencing some problems. I set nginx proxy to apache and it does work with proxy_pass app1.mydomain.com:80; but it does not work with proxy_pass 127.0.0.1:80; - something in apache should be set up I guess...
â Student Michal Wloga
Apr 9 at 21:13
Thank you. It was what I was looking for. I am still experiencing some problems. I set nginx proxy to apache and it does work with proxy_pass app1.mydomain.com:80; but it does not work with proxy_pass 127.0.0.1:80; - something in apache should be set up I guess...
â Student Michal Wloga
Apr 9 at 21:13
add a comment |Â
up vote
0
down vote
By the content of your question, you already have it worked out, except that you can only access one application per port #. You can't run both Apache2 and Nginx on the same port. It's not possible.
Since you've mentioned you already have your DNS working and pointing to the correct machine (IP). You can reach your app1.mydomain.com
by the default (port 80
) with:
http://app1.mydomain.com
That's the same as
http://app1.mydomain.com:80
You will have to specify the port for your Nginx, which you have, by your configuration file, set for port 8080
.
Use this to access your site1:
http://app1.mydomain.com:8080
If you specify the wrong port, the default page will load regardless of the domainname used. For Apache, the default is the first virtual host, unless specified different.
But the goal is to connect app1.mydomain.com with Apache and app2.mydomain.com with Nginx. Both with port 80 so that user is not forced to specify port.
â Student Michal Wloga
Apr 8 at 16:26
In that case you can have one server refresh and reload to the alternate server.
â L. D. James
Apr 8 at 16:30
add a comment |Â
up vote
0
down vote
By the content of your question, you already have it worked out, except that you can only access one application per port #. You can't run both Apache2 and Nginx on the same port. It's not possible.
Since you've mentioned you already have your DNS working and pointing to the correct machine (IP). You can reach your app1.mydomain.com
by the default (port 80
) with:
http://app1.mydomain.com
That's the same as
http://app1.mydomain.com:80
You will have to specify the port for your Nginx, which you have, by your configuration file, set for port 8080
.
Use this to access your site1:
http://app1.mydomain.com:8080
If you specify the wrong port, the default page will load regardless of the domainname used. For Apache, the default is the first virtual host, unless specified different.
But the goal is to connect app1.mydomain.com with Apache and app2.mydomain.com with Nginx. Both with port 80 so that user is not forced to specify port.
â Student Michal Wloga
Apr 8 at 16:26
In that case you can have one server refresh and reload to the alternate server.
â L. D. James
Apr 8 at 16:30
add a comment |Â
up vote
0
down vote
up vote
0
down vote
By the content of your question, you already have it worked out, except that you can only access one application per port #. You can't run both Apache2 and Nginx on the same port. It's not possible.
Since you've mentioned you already have your DNS working and pointing to the correct machine (IP). You can reach your app1.mydomain.com
by the default (port 80
) with:
http://app1.mydomain.com
That's the same as
http://app1.mydomain.com:80
You will have to specify the port for your Nginx, which you have, by your configuration file, set for port 8080
.
Use this to access your site1:
http://app1.mydomain.com:8080
If you specify the wrong port, the default page will load regardless of the domainname used. For Apache, the default is the first virtual host, unless specified different.
By the content of your question, you already have it worked out, except that you can only access one application per port #. You can't run both Apache2 and Nginx on the same port. It's not possible.
Since you've mentioned you already have your DNS working and pointing to the correct machine (IP). You can reach your app1.mydomain.com
by the default (port 80
) with:
http://app1.mydomain.com
That's the same as
http://app1.mydomain.com:80
You will have to specify the port for your Nginx, which you have, by your configuration file, set for port 8080
.
Use this to access your site1:
http://app1.mydomain.com:8080
If you specify the wrong port, the default page will load regardless of the domainname used. For Apache, the default is the first virtual host, unless specified different.
answered Apr 8 at 16:20
L. D. James
17.5k43178
17.5k43178
But the goal is to connect app1.mydomain.com with Apache and app2.mydomain.com with Nginx. Both with port 80 so that user is not forced to specify port.
â Student Michal Wloga
Apr 8 at 16:26
In that case you can have one server refresh and reload to the alternate server.
â L. D. James
Apr 8 at 16:30
add a comment |Â
But the goal is to connect app1.mydomain.com with Apache and app2.mydomain.com with Nginx. Both with port 80 so that user is not forced to specify port.
â Student Michal Wloga
Apr 8 at 16:26
In that case you can have one server refresh and reload to the alternate server.
â L. D. James
Apr 8 at 16:30
But the goal is to connect app1.mydomain.com with Apache and app2.mydomain.com with Nginx. Both with port 80 so that user is not forced to specify port.
â Student Michal Wloga
Apr 8 at 16:26
But the goal is to connect app1.mydomain.com with Apache and app2.mydomain.com with Nginx. Both with port 80 so that user is not forced to specify port.
â Student Michal Wloga
Apr 8 at 16:26
In that case you can have one server refresh and reload to the alternate server.
â L. D. James
Apr 8 at 16:30
In that case you can have one server refresh and reload to the alternate server.
â L. D. James
Apr 8 at 16:30
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1023103%2fnginx-and-apache2-on-same-server%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
Possible duplicate of How do I configure my DNS settings in Ubuntu server?
â Elder Geek
Apr 8 at 15:23
@ElderGeek It's not a duplicate of that. I don't believe it has anything to do with DNS even.
â vidarlo
Apr 8 at 16:39
@vidarlo your edit makes that clear. I hope that corresponds with the OP's intent.
â Elder Geek
Apr 8 at 20:01