Hosting multiple apps on Nginx Ubuntu 14.04
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I am having hard time finding a solution. I have a Ubuntu 14.04 machine running NGINX. I have below 2 folders I would like to host.
/var/www/apphost.comp.ill.com/app1/home/index.html
/var/www/apphost.comp.ill.com/app2/index.html
I would like to open app1's index file when I go to "apphost.comp.ill.com/app1" and open app2's index file when I go to "apphost.comp.ill.com/app2".
I believe I need to edit "/etc/nginx/sites-available/apphost.comp.ill.com" to make it happen but I can't seem to figure out how. I tried multiple things, searched online but could not find any solution. Here is how my file looks like currently:
server {
listen 80;
listen [::]:80;
root /var/www/apphost.comp.ill.com/app1/home;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
It works for app1 when I go to apphost.comp.ill.com. How can I make it so it works when I go to "apphost.comp.ill.com/app1" and also add app2 to work when I go to "apphost.comp.ill.com/app2".
Please help. Thanks
ubuntu nginx hosting-services
add a comment |Â
up vote
1
down vote
favorite
I am having hard time finding a solution. I have a Ubuntu 14.04 machine running NGINX. I have below 2 folders I would like to host.
/var/www/apphost.comp.ill.com/app1/home/index.html
/var/www/apphost.comp.ill.com/app2/index.html
I would like to open app1's index file when I go to "apphost.comp.ill.com/app1" and open app2's index file when I go to "apphost.comp.ill.com/app2".
I believe I need to edit "/etc/nginx/sites-available/apphost.comp.ill.com" to make it happen but I can't seem to figure out how. I tried multiple things, searched online but could not find any solution. Here is how my file looks like currently:
server {
listen 80;
listen [::]:80;
root /var/www/apphost.comp.ill.com/app1/home;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
It works for app1 when I go to apphost.comp.ill.com. How can I make it so it works when I go to "apphost.comp.ill.com/app1" and also add app2 to work when I go to "apphost.comp.ill.com/app2".
Please help. Thanks
ubuntu nginx hosting-services
I don't know much about Nginx but is the mix of slashes / and backslashes intentional?
â dreua
Dec 6 '17 at 22:50
Not intentional .. fixed
â Neo
Dec 6 '17 at 22:57
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am having hard time finding a solution. I have a Ubuntu 14.04 machine running NGINX. I have below 2 folders I would like to host.
/var/www/apphost.comp.ill.com/app1/home/index.html
/var/www/apphost.comp.ill.com/app2/index.html
I would like to open app1's index file when I go to "apphost.comp.ill.com/app1" and open app2's index file when I go to "apphost.comp.ill.com/app2".
I believe I need to edit "/etc/nginx/sites-available/apphost.comp.ill.com" to make it happen but I can't seem to figure out how. I tried multiple things, searched online but could not find any solution. Here is how my file looks like currently:
server {
listen 80;
listen [::]:80;
root /var/www/apphost.comp.ill.com/app1/home;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
It works for app1 when I go to apphost.comp.ill.com. How can I make it so it works when I go to "apphost.comp.ill.com/app1" and also add app2 to work when I go to "apphost.comp.ill.com/app2".
Please help. Thanks
ubuntu nginx hosting-services
I am having hard time finding a solution. I have a Ubuntu 14.04 machine running NGINX. I have below 2 folders I would like to host.
/var/www/apphost.comp.ill.com/app1/home/index.html
/var/www/apphost.comp.ill.com/app2/index.html
I would like to open app1's index file when I go to "apphost.comp.ill.com/app1" and open app2's index file when I go to "apphost.comp.ill.com/app2".
I believe I need to edit "/etc/nginx/sites-available/apphost.comp.ill.com" to make it happen but I can't seem to figure out how. I tried multiple things, searched online but could not find any solution. Here is how my file looks like currently:
server {
listen 80;
listen [::]:80;
root /var/www/apphost.comp.ill.com/app1/home;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
It works for app1 when I go to apphost.comp.ill.com. How can I make it so it works when I go to "apphost.comp.ill.com/app1" and also add app2 to work when I go to "apphost.comp.ill.com/app2".
Please help. Thanks
ubuntu nginx hosting-services
edited Dec 6 '17 at 22:57
asked Dec 6 '17 at 21:15
Neo
134
134
I don't know much about Nginx but is the mix of slashes / and backslashes intentional?
â dreua
Dec 6 '17 at 22:50
Not intentional .. fixed
â Neo
Dec 6 '17 at 22:57
add a comment |Â
I don't know much about Nginx but is the mix of slashes / and backslashes intentional?
â dreua
Dec 6 '17 at 22:50
Not intentional .. fixed
â Neo
Dec 6 '17 at 22:57
I don't know much about Nginx but is the mix of slashes / and backslashes intentional?
â dreua
Dec 6 '17 at 22:50
I don't know much about Nginx but is the mix of slashes / and backslashes intentional?
â dreua
Dec 6 '17 at 22:50
Not intentional .. fixed
â Neo
Dec 6 '17 at 22:57
Not intentional .. fixed
â Neo
Dec 6 '17 at 22:57
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
accepted
I tried this and it works:
server
listen 80;
listen [::]:80;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /app1
# we need to use alias here to strip the "app1" from
# the requested path
alias /var/www/apphost.comp.ill.com/app1/home;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
location /app2
# we don't need an alias here because app2 matches the
# directory structure
root /var/www/apphost.comp.ill.com/;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
I would recommend /app1 and /app2 without a leading slash because in my test browsing to .../app1 didn't work otherwise.
Documentation of the alias command: http://nginx.org/en/docs/http/ngx_http_core_module.html#alias
That worked ... thanks
â Neo
Dec 13 '17 at 23:41
add a comment |Â
up vote
0
down vote
Edit: This answer is wrong, because the part after "location" will be appended to the document root. (i.e. nginx tries to open the file /var/www/apphost.comp.ill.com/app1/home/app1/index.html) I should not have posted it without trying first, sorry.
Have you tried:
server
listen 80;
listen [::]:80;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /app1/
root /var/www/apphost.comp.ill.com/app1/home;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
location /app2/
root /var/www/apphost.comp.ill.com/app2;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
That did not work
â Neo
Dec 7 '17 at 20:40
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
I tried this and it works:
server
listen 80;
listen [::]:80;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /app1
# we need to use alias here to strip the "app1" from
# the requested path
alias /var/www/apphost.comp.ill.com/app1/home;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
location /app2
# we don't need an alias here because app2 matches the
# directory structure
root /var/www/apphost.comp.ill.com/;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
I would recommend /app1 and /app2 without a leading slash because in my test browsing to .../app1 didn't work otherwise.
Documentation of the alias command: http://nginx.org/en/docs/http/ngx_http_core_module.html#alias
That worked ... thanks
â Neo
Dec 13 '17 at 23:41
add a comment |Â
up vote
0
down vote
accepted
I tried this and it works:
server
listen 80;
listen [::]:80;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /app1
# we need to use alias here to strip the "app1" from
# the requested path
alias /var/www/apphost.comp.ill.com/app1/home;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
location /app2
# we don't need an alias here because app2 matches the
# directory structure
root /var/www/apphost.comp.ill.com/;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
I would recommend /app1 and /app2 without a leading slash because in my test browsing to .../app1 didn't work otherwise.
Documentation of the alias command: http://nginx.org/en/docs/http/ngx_http_core_module.html#alias
That worked ... thanks
â Neo
Dec 13 '17 at 23:41
add a comment |Â
up vote
0
down vote
accepted
up vote
0
down vote
accepted
I tried this and it works:
server
listen 80;
listen [::]:80;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /app1
# we need to use alias here to strip the "app1" from
# the requested path
alias /var/www/apphost.comp.ill.com/app1/home;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
location /app2
# we don't need an alias here because app2 matches the
# directory structure
root /var/www/apphost.comp.ill.com/;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
I would recommend /app1 and /app2 without a leading slash because in my test browsing to .../app1 didn't work otherwise.
Documentation of the alias command: http://nginx.org/en/docs/http/ngx_http_core_module.html#alias
I tried this and it works:
server
listen 80;
listen [::]:80;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /app1
# we need to use alias here to strip the "app1" from
# the requested path
alias /var/www/apphost.comp.ill.com/app1/home;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
location /app2
# we don't need an alias here because app2 matches the
# directory structure
root /var/www/apphost.comp.ill.com/;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
I would recommend /app1 and /app2 without a leading slash because in my test browsing to .../app1 didn't work otherwise.
Documentation of the alias command: http://nginx.org/en/docs/http/ngx_http_core_module.html#alias
answered Dec 9 '17 at 18:19
dreua
1857
1857
That worked ... thanks
â Neo
Dec 13 '17 at 23:41
add a comment |Â
That worked ... thanks
â Neo
Dec 13 '17 at 23:41
That worked ... thanks
â Neo
Dec 13 '17 at 23:41
That worked ... thanks
â Neo
Dec 13 '17 at 23:41
add a comment |Â
up vote
0
down vote
Edit: This answer is wrong, because the part after "location" will be appended to the document root. (i.e. nginx tries to open the file /var/www/apphost.comp.ill.com/app1/home/app1/index.html) I should not have posted it without trying first, sorry.
Have you tried:
server
listen 80;
listen [::]:80;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /app1/
root /var/www/apphost.comp.ill.com/app1/home;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
location /app2/
root /var/www/apphost.comp.ill.com/app2;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
That did not work
â Neo
Dec 7 '17 at 20:40
add a comment |Â
up vote
0
down vote
Edit: This answer is wrong, because the part after "location" will be appended to the document root. (i.e. nginx tries to open the file /var/www/apphost.comp.ill.com/app1/home/app1/index.html) I should not have posted it without trying first, sorry.
Have you tried:
server
listen 80;
listen [::]:80;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /app1/
root /var/www/apphost.comp.ill.com/app1/home;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
location /app2/
root /var/www/apphost.comp.ill.com/app2;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
That did not work
â Neo
Dec 7 '17 at 20:40
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Edit: This answer is wrong, because the part after "location" will be appended to the document root. (i.e. nginx tries to open the file /var/www/apphost.comp.ill.com/app1/home/app1/index.html) I should not have posted it without trying first, sorry.
Have you tried:
server
listen 80;
listen [::]:80;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /app1/
root /var/www/apphost.comp.ill.com/app1/home;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
location /app2/
root /var/www/apphost.comp.ill.com/app2;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
Edit: This answer is wrong, because the part after "location" will be appended to the document root. (i.e. nginx tries to open the file /var/www/apphost.comp.ill.com/app1/home/app1/index.html) I should not have posted it without trying first, sorry.
Have you tried:
server
listen 80;
listen [::]:80;
index index.html index.htm home home.html;
# Make site accessible from http://localhost/
server_name apphost.comp.ill.com;
location /app1/
root /var/www/apphost.comp.ill.com/app1/home;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
location /app2/
root /var/www/apphost.comp.ill.com/app2;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
edited Dec 9 '17 at 18:08
answered Dec 6 '17 at 23:36
dreua
1857
1857
That did not work
â Neo
Dec 7 '17 at 20:40
add a comment |Â
That did not work
â Neo
Dec 7 '17 at 20:40
That did not work
â Neo
Dec 7 '17 at 20:40
That did not work
â Neo
Dec 7 '17 at 20:40
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
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%2funix.stackexchange.com%2fquestions%2f409315%2fhosting-multiple-apps-on-nginx-ubuntu-14-04%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
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');
);
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');
);
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
I don't know much about Nginx but is the mix of slashes / and backslashes intentional?
â dreua
Dec 6 '17 at 22:50
Not intentional .. fixed
â Neo
Dec 6 '17 at 22:57