使Nginx指向/var/www/之外的特定index.html页面 [英] Getting Nginx to point to a specific index.html page outside of /var/www/
本文介绍了使Nginx指向/var/www/之外的特定index.html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图让nginx指向我的index.html页面以及位于/var/www/之外的GoPATH中的img,CSS,JS等.我的总体目标是允许我的网站在端口80而不是8080上运行.是否可以这样做?以下是我目前在nginx.conf中拥有的内容.
I'm trying to get nginx to point to my index.html page along with imgs, CSS, JS, etc. that lies in a GoPATH, which is outside of /var/www/. My overall objective is to allow my website to run on port 80 and not 8080. Is it possible to do this? Below is what I currently have in the nginx.conf.
user www-data;
http {
include /etc/nginx/proxy.conf;
index index.html
}
server { # simple reverse-proxy
listen 80;
server_name dtrinh.com www.dtrinh.com;
access_log logs/dtrinh.access.log main;
# serve static files
# serve static files
location / {
root /go/src/ps/views/default/index.html;
expires 30d;
# pass requests for dynamic content to rails/turbogears/zope, et al
location / {
proxy_pass http://127.0.0.1:8080;
}
}
推荐答案
location / {
root /go/src/ps/views/default;
error_page 404 = @backend;
expires 30d;
}
location @backend {
proxy_pass http://127.0.0.1:8080;
}
参考:
- http://nginx.org/r/root
- http://nginx.org/r/error_page
- http://nginx.org/r/location
这篇关于使Nginx指向/var/www/之外的特定index.html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文