- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
几天来我一直在这个问题上苦思冥想,终于碰壁了。
我一直在尝试让我的堆栈运行:
我一直在看其他一些像这样的 SO 文章:
nginx - uWSGI HTTP + websocket config
他们似乎遇到了我遇到的类似问题,但解决方案对我不起作用。
基本上,每当我尝试启动我的 uWSGI 进程时,我都会遇到 nginx 502 错误的网关屏幕。按照文档中的说明,我有两个单独的 uwsgi 进程正在运行。
当我运行 websocket uwsgi 实例时,我得到以下信息:
*** running gevent loop engine [addr:0x487690] ***
[2015-05-27 00:45:34,119 wsgi_server] DEBUG: Subscribed to channels: subscribe-broadcast, publish-broadcast
这告诉我 uwsgi 实例运行正常。然后我运行我的下一个 uwsgi 进程,那里也没有错误日志......
当我在浏览器中导航到该页面时,该页面会挂起几秒钟,然后出现 502 Bad Gateway 屏幕。
根据 NGINX 日志,NGINX 说:
2015/05/26 22:46:08 [error] 18044#0: *3855 upstream prematurely closed connection while reading response header from upstream, client: 192.168.59.3, server: , request: "GET /chat/ HTTP/1.1", upstream: "uwsgi://unix:/opt/django/django.sock:", host: "192.168.59.103:32768"
这是我尝试在网络浏览器中访问该页面时收到的唯一错误日志。
有什么想法吗???
以下是我的一些配置文件:
nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/django.conf;
}
我有以下 django.conf 文件,它扩展了 nginx.conf
upstream django {
server unix:/opt/django/django.sock;
}
server {
listen 80 default_server;
charset utf-8;
client_max_body_size 20M;
sendfile on;
keepalive_timeout 0;
large_client_header_buffers 8 32k;
location /media {
alias /opt/django/app/media/media;
}
location /static {
alias /opt/django/app/static;
}
location / {
include /opt/django/uwsgi_params;
}
location /ws/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://unix:/opt/django/app.sock;
proxy_buffers 8 32k;
proxy_buffer_size 64k;
}
}
负责我的 uwsgi 进程的两个文件如下:
runserver_uwsgi.ini:
[uwsgi]
ini = :runserver
[default]
userhome = /opt/django
chdir = %dapp/
master = true
module = chatserver.wsgi:application
no-orphans = true
threads = 1
env = DJANGO_SETTINGS_MODULE=myapp.settings
vacuum = true
[runserver]
ini = :default
socket = /opt/django/app.sock
module = wsgi_django
buffer-size = 32768
processes = 4
chmod-socket=666
和 wsserver_uwsgi.ini
[uwsgi]
ini = :wsserver
[default]
userhome = /opt/django
chdir = %dapp/
master = true
module = chatserver.wsgi:application
no-orphans = true
threads = 1
env = DJANGO_SETTINGS_MODULE=chatserver.settings
vacuum = true
[wsserver]
ini = :default
http-socket = /opt/django/django.sock
module = wsgi_websocket
http-websockets = true
processes = 2
gevent = 1000
chmod-socket=666
最佳答案
我发现了问题。
我的 [runserver] 套接字 (app.sock) 应该指向 upstream django
而我的 [wsserver] 套接字 (django.sock) 应该指向 location/ws/
像这样:
upstream django {
server unix:/opt/django/app.sock;
}
server {
listen 80 default_server;
charset utf-8;
client_max_body_size 20M;
sendfile on;
keepalive_timeout 0;
large_client_header_buffers 8 32k;
location /media {
alias /opt/django/app/media/media;
}
location /static {
alias /opt/django/app/static;
}
location / {
include /opt/django/uwsgi_params;
}
location /ws/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://unix:/opt/django/django.sock;
proxy_buffers 8 32k;
proxy_buffer_size 64k;
}
}
关于django - nginx uwsgi websockets 502 Bad Gateway upstream 在从上游读取响应 header 时过早关闭连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30470448/
Spring Cloud Greenwich puts spring-cloud-netflix-zuul处于维护模式,所以我正在尝试从 Zuul 迁移到 Spring Cloud Gateway。
有没有办法对 AWS API Gateway 服务使用基本身份验证而不是 AWS4-HMAC-SHA256 身份验证?我需要支持仅支持使用基本身份验证的 webhook 调用的系统。 最佳答案 您只需
Rails API 通常喜欢这样的数组查询参数: example.com?colors[]=cyan&colors[]=magenta&colors[]=yellow&colors[]=black 我
Here蓝图中说,API 网关将响应 401: Unauthorized。 我写了同样的raise Exception('Unauthorized')在我的 lambda 中,并且能够从 Lambda
在 documentation我确实看到了如何使用 Hystrix 实现超时,但我只想确保没有实现默认超时。 最佳答案 现在还有一个 chapter关于文档中的一般超时。可以设置全局超时和每条路由超时
我的资源/api 有一个方法 POST,它将主体代理到 Kinesis Firehose(然后代理到 ES)。同时我希望它触发一个 Lambda 函数。 我尝试添加一个额外的方法 ANY 来触发 La
Spring Cloud Gateway 真的很新 - 但它“似乎”很容易。我真的很苦恼的一个问题。我的要求是为路径添加前缀,检查头变量,根据该变量查找 URI,然后继续前进。 问题是 uri 总是下
我已经使用 Websocket 协议(protocol)创建了一个 API 网关。部署 API 后,我得到一个 WebSocket URL 和一个连接 URL。 例如 WebSocket URL:ws
我正在使用 AWS API Gateway 和 AWS Lambda 创建一个无服务器的 REST API。虽然已创建端点并与相应的 Lambda 函数链接,但下一步是添加身份验证层以通过电子邮件和密
我们开发了一个应用程序,它提供多种休息服务,并支持 Accept-Encoding header ,以通过 Content-Encoding:gzip header 值返回压缩内容。 此应用程序部署在
我正在开发 CloudFormation 模板来部署 API Gateway 资源,但在部署 (AWS::ApiGateway::Deployment) 和UsagePlan 资源方面遇到问题。这有点
我目前正在使用 AWS API Gateway 开发 API。我正在向我的客户发布一个 JSON Web token (JWT)。该 JWT 使用 secret 进行签名。我目前将 secret 存储
我下载了 .NET SDK对于 Payflow Gateway 并遵循 these instructions关于设置我的 Payflow Gateway 测试帐户,然后修改两行 DOSecureTok
我目前正在将 Amazon CloudSearch 与前端应用程序集成。由于已知的 CORS 问题,我也被迫使用 API 网关。 出现的问题是,前端 CloudSearch 库发送带有编码参数的 ur
我正在创建一个 LambdaRestApi在 CDK 中,我想同时启用 CORS 并使用 addProxy 方法添加任何代理。 我目前有以下 CDK 代码: const api = new Lam
我们可以使用 AWS API Gateway 使用双向 SSL 功能吗?我们希望在我们的实时流应用程序中使用 API Gateway 作为 kinesis 的代理。 下面是我的要求 客户端向 apig
我正在构建一个无服务器 react 应用程序,它使用 Cognito 进行登录/注销。该应用程序调用 API 网关,该网关配置为使用 Cognito 用户池作为自定义授权方。 我还构建了一个 lamb
我已经浏览了 Google Cloud API Gateway docs并搜索 the public issue tracker但一直无法以某种方式提及它。 我最接近的是this google gro
我正在尝试将使用 spring-cloud-starter-netflix-zuul 的网关迁移到 Spring Cloud Gateway,但我遇到了请求路由问题。 我浏览了以下有关为 Discov
我正在尝试设置我的 API 网关,以便它具有以下简单的方法响应: 我正在使用 CloudFormation,但总是遇到错误。我相信这很简单,但在花了几个小时阅读文档后我陷入了困境。这是我的方法资源(在
我是一名优秀的程序员,十分优秀!