nginx and apache2 on same server

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








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;










share|improve this question



















  • 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














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;










share|improve this question



















  • 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












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;










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 8 at 16:28









vidarlo

7,14342140




7,14342140










asked Apr 8 at 15:14









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












  • 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










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:



  1. 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.

  2. 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.






share|improve this answer




















  • 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


















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.






share|improve this answer




















  • 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










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























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:



  1. 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.

  2. 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.






share|improve this answer




















  • 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















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:



  1. 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.

  2. 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.






share|improve this answer




















  • 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













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:



  1. 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.

  2. 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.






share|improve this answer












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:



  1. 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.

  2. 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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 8 at 16:26









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

















  • 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













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.






share|improve this answer




















  • 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














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.






share|improve this answer




















  • 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












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.






share|improve this answer












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.







share|improve this answer












share|improve this answer



share|improve this answer










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
















  • 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

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Popular posts from this blog

pylint3 and pip3 broken

Missing snmpget and snmpwalk

How to enroll fingerprints to Ubuntu 17.10 with VFS491