我正在使用Django + Apache和Nginx构建一个网站来提供我的静态内容。我的网站的索引不需要任何后端Django编码,所以我需要在nginx.conf中更改以将位置/ {}的请求发送到我的静态内容中的某些index.html,同时仍允许我的urls.py处理模式适当吗?
upstream backend {
server 127.0.0.1:8080;
}
server {
listen 192.168.1.20:80;
server_name www.example.com example.com;
access_log /home/userxyz/public_html/example.com/logs/nginx_access.log;
error_log /home/userxyz/public_html/example.com/logs/nginx_error.log;
location /
{
proxy_pass http://127.0.0.1:8080;
include /etc/nginx/proxy.conf;
}
location ~ ^/(system|images|robots\.txt|css|js|favicon\.ico).*$
{
root /home/userxyz/public_html/example.com/static-content/;
}
location /media/
{
root /home/userxyz/public_html/example.com/;
}
}
答案 0 :(得分:1)
location = / {
root /home/userxyz/public_html/example.com/static-content/;
}
答案 1 :(得分:0)
如下:
location ~ ^/$
{
root /PATH/TO/index.html;
}
这个想法是给nginx一个完全匹配'/'的规则。