【发布时间】:2019-10-18 03:37:36
【问题描述】:
我正在尝试在谷歌云平台上部署我的 django 应用程序。我正在使用 nginx 和 gunicorn。我关注this guide。
我创建了一个文件 - le_website - 在文件夹可用的站点下。这是代码 -
server {
listen 80;
server_name 10.xxx.x.x;
location = /favicon.ico {access_log off;log_not_found off;}
location = /static/ {
root /home/jainpriyanshu1991/learnEarn/le-webiste;
}
location = / {
include proxy_params;
proxy_pass http://unix:/home/jainpriyanshu1991/learnEarn/le-webiste/le_website.sock;
}
}
当我尝试使用 url myIPaddress/static/ 时,它可以工作并显示其中的文件夹。但它不适用于静态中的任何子文件夹。它给出/usr/share/nginx/html/static/img/index.html is not found for img folder inside static。同样,当我尝试使用 url myIPaddress/ 时,它会打开网站的主页,但同样,它不适用于任何其他链接并给出错误。对于 about 页面,它给出错误 /usr/share/nginx/html/about failed (2: No such file or directory)。
【问题讨论】:
-
您的意思是在最后两个
location块中使用=修饰符吗?试试看:location /static/ { ... } location / { ... } -
@RichardSmith 您能否添加您的评论作为答案,以便让社区的其他成员看到?谢谢。
标签: django nginx google-cloud-platform gunicorn