标签: flask

Nginx 看不到 unix 套接字

更新:我看到了与 /tmp 目录相关的问题,还有一条评论提到将套接字移出 /home 以及。它没有解决问题。

(帖子底部的其他更新)

我在 azure 上有一个ubuntu 16.04 vm我正在使用uwsgi作为服务器和nginx作为反向代理来托管烧瓶应用程序,遵循本指南...

https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-16-04

问题是当我尝试使用端口 80 上的 Web 浏览器连接到服务器的 ip 时,我收到了502 Bad Gateway。当我检查日志时,它说 nginx 找不到我在配置文件中指定的 unix 套接字.

错误是...

2016/08/29 23:23:20 [crit] 2792#2792: *120 connect() to unix:///home/me/appname/appname/appname.sock failed (2: No such file or directory) while connecting to upstream, client: ip.goes.in.here, server: here.goes.the.ip, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///home/me/appname/appname/appname.sock:", host: "the.ip.goes.here", referrer: "http://all.of.teh.ips/"
Run Code Online (Sandbox Code Playgroud)

我的服务器块看起来像这样......

server {
  listen 80;
  server_name ip.address.goes.here;

  location …
Run Code Online (Sandbox Code Playgroud)

linux ubuntu nginx uwsgi flask

6
推荐指数
1
解决办法
7768
查看次数

在airflow的配置文件“airflow.cfg”中,“secret_key”是什么,我必须设置它吗?

作为价值之上的评论,它说# Secret key used to run your flask app,但这并没有告诉我太多信息。目前它设置为secret_key = temporary_key,但这似乎不安全。我们在 Web 服务上设置了密码保护,并由运行在 Ubuntu 14/16 上的 postgres 支持。

configuration flask

6
推荐指数
1
解决办法
1万
查看次数

Apache 2.4 验证匿名用户但允许其他人通过 IP

我正在尝试将 Apache 配置为允许用户从选择的 IP 访问 Flask 应用程序而无需身份验证,但要向任何其他用户挑战凭据。

就目前情况而言,我有以下配置:

<directory /var/www/flaskapp>
    WSGIProcessGroup flaskapp
    WSGIApplicationGroup %{GLOBAL}
    WSGIScriptReloading On
    WSGIPassAuthorization On
    Order deny,allow
    AuthType Basic
    AuthName "Restricted area - authorised users only"
    AuthUserFile "/usr/local/apache/passwd"
    <RequireAll>
        <RequireAny>
            Require ip 1.1.1.1
         </RequireAny>
        Require valid-user
    </RequireAll>
</directory>
Run Code Online (Sandbox Code Playgroud)

这不起作用,而是提示所有用户进行身份验证。

我应该提到我曾经在配置中指示htpasswd的位置创建一个用户文件/usr/local/apache/passwd

.htaccess flask apache-2.4

6
推荐指数
1
解决办法
1374
查看次数

nginx + uwsgi - 什么是静态文件?

我使用 nginx 作为几个 Flask 应用程序的代理,使用 uwsgi 作为中间件。这是我的测试应用程序的 nginx 配置。


server {
    listen      80;
    server_name test.myapp.com www.test.myapp.com;
    charset     utf-8;
    client_max_body_size 250M;
    location / { try_files $uri @testapp; }

location @testapp {
    include uwsgi_params;
    uwsgi_pass unix:/tmp/testapp_uwsgi.sock;
}

location /forecaster/components/ {
    alias /opt/test/client/app/components/;
}
Run Code Online (Sandbox Code Playgroud)

}

Run Code Online (Sandbox Code Playgroud)

我很确定 nginx 实际上并没有为静态文件提供服务,即使我注释掉了该location块,文件也是从某些东西中获取的。我在 nginx 日志中看到了 200 个,在 uWsgi 日志中也看到了 200 个。你怎么知道哪个是服务静态文件的?我想烧瓶应用程序也可以为他们服务?

/opt/test/client/app/components/ 肯定存在,并且对其他人可读。有什么方法可以强制 uwsgi 不处理这些请求?

python nginx uwsgi flask

5
推荐指数
1
解决办法
1万
查看次数

如果应用程序映射到子目录,如何在 Nginx + Flask 设置中加载静态文件

我有一个在域(例如 example.com)上运行的基本 html 站点,我想在子目录(例如:example.com/test)中运行一个flask应用程序,flask应用程序使用默认的flask开发在端口5433上运行服务器。

我使用以下 nginx 配置来实现这一点

location /test {
        rewrite /test(.*) $1 break;
        proxy_pass http://localhost:5433;
        proxy_redirect     default;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    }

    location /static/{
        alias /home/hrishi/www/example.com/test/app/static/;
    }
Run Code Online (Sandbox Code Playgroud)

我可以使用 example.com/test/ url 访问该应用程序,但尽管有别名,静态文件仍无法加载(给出 404 错误)。

我怎样才能解决这个问题?

更新:按照说明添加整个服务器块

 server {

    listen   *:80 default_server; ## listen for ipv4; this line is default and implied
    #listen   [::]:80; # listen for ipv6

    root /home/hrishi/www/example.com/;
    index index.php index.html index.htm;

    # Make site accessible from http://localhost/
    server_name example.com;

    # Logging
    access_log …
Run Code Online (Sandbox Code Playgroud)

nginx flask

2
推荐指数
1
解决办法
2659
查看次数

标签 统计

flask ×5

nginx ×3

uwsgi ×2

.htaccess ×1

apache-2.4 ×1

configuration ×1

linux ×1

python ×1

ubuntu ×1