我很难找到解决方案。我有一台运行 NGINX 的 Ubuntu 14.04 机器。我想托管以下 2 个文件夹。
/var/www/apphost.comp.ill.com/app1/home/index.html /var/www/apphost.comp.ill.com/app2/index.html
我想在转到“apphost.comp.ill.com/app1”时打开 app1 的索引文件,在转到“apphost.comp.ill.com/app2”时打开 app2 的索引文件。
我相信我需要编辑“/etc/nginx/sites-available/apphost.comp.ill.com”来实现它,但我似乎无法弄清楚如何。我尝试了多种方法,在线搜索但找不到任何解决方案。这是我的文件当前的样子:
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
}
当我访问 apphost.comp.ill.com 时,它适用于 app1。我怎样才能让它在我去“apphost.comp.ill.com/app1”时工作,并且在我去“apphost.comp.ill.com/app2”时添加app2工作。
请帮忙。谢谢