flask从服务器加载静态文件,Nginx不会加载Flask静态文件

新的flask/nginx/uWSGI服务器。应用程序加载和函数的预期,但非HTML/CSS模板将加载。在Chrome中使用开发人员工具显示页面未被退回。Nginx不会加载Flask静态文件

“tail -f /var/log/nginx/error.log”表示文件或目录不存在。但它似乎是正确的道路。完整路径为“/opt/netmgmt/app/static/css/main.css”

2016/09/15 22:04:40 [error] 4939#0: *1 open() "/app/static/css/main.css" failed (2: No such file or directory), client: 10.0.0.69, server: , request: "GET /static/css/main.css HTTP/1.1", host: "nms-srv2", referrer: "http://nms-srv2/"

烧瓶调试完全没有问题。 我一直对我的头撞这一段时间,发现多个其他线程有同样的问题,但没有任何解决这个问题。

感谢您的帮助!

/etc/nginx/nginx.conf

worker_processes 1;

events {

worker_connections 1024;

}

http {

sendfile on;

gzip on;

gzip_http_version 1.0;

gzip_proxied any;

gzip_min_length 500;

gzip_disable "MSIE [1-6]\.";

gzip_types text/plain text/xml text/css

text/comma-separated-values

text/javascript

application/x-javascript

application/atom+xml;

# Configuration containing list of application servers

upstream uwsgicluster {

server 127.0.0.1:8080;

# server 127.0.0.1:8081;

# ..

# .

}

# Configuration for Nginx

server {

# Running port

listen 80;

# Settings to by-pass for static files

location ^~ /static/ {

# Example:

# root /full/path/to/application/static/file/dir;

root /app/;

}

# Serve a static file (ex. favico) outside static dir.

location = /favico.ico {

root /app/favico.ico;

}

# Proxying connections to application servers

location/{

include uwsgi_params;

uwsgi_pass uwsgicluster;

proxy_redirect off;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-Forwarded-Host $server_name;

}

应用程序文件(伊夫试图改变静态位置多种方式和使用别名,而不是根源,没有运气。)

@app.route('/')

def home():

return render_template('home.html')

布局。 html

NetMgmt

{% block content %}

{% endblock %}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值