[英]502 Bad Gateway error with python app running uwsgi and nginx (centos)
Seen this question asked but all seemed to be Ubuntu and the solutions didn't quite work for me on Centos. 看到有人问了这个问题,但似乎都是Ubuntu,解决方案在Centos上对我而言并不奏效。 I have a flask app trying to run from uwsgi and am getting 我有一个烧瓶应用程序试图从uwsgi运行并越来越
2017/07/26 17:44:24 [crit] 22785#0: *7 connect() to unix:/home/myname/perm_check/index.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: 127.0.0.1, request: "GET / HTTP/1.1", upstream: "uwsgi://unix:/home/myname/perm_check/index.sock:", host: "127.0.0.1"
(it runs fine from virtualenv to localhost:500 or localhost:8000 with wsgi as per this https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-centos-7 tutorial. (根据此https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx,它可以通过wsgi从virtualenv正常运行到localhost:500或localhost:8000 -on-centos-7教程。
Here are my files: index.ini 这是我的文件:index.ini
[uwsgi]
module = wsgi
master = true
processes = 5
socket = index.sock
chmod-socket = 664
vacuum = true
die-on-term = true
index.py index.py
from flask import Flask
app = Flask(__name__)
@app.route("/")
def check():
return "<h1 style='color:red'>Test run...</h1>"
if __name__ == "__main__":
app.run(host='0.0.0.0')
nginx.conf nginx.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name 127.0.0.1;
location / {
include uwsgi_params;
uwsgi_pass unix:/home/myname/perm_check/index.sock;
}
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}
I know I'm missing something simple somewhere but I can't for the life of me figure it out. 我知道我在某个地方缺少一些简单的东西,但是我一生都无法解决。 Permissions for everything is myname:myname and I'm trying to run the uwsgi service from 127.0.0.1. 一切权限均为myname:myname ,我正在尝试从127.0.0.1运行uwsgi服务。
解决了此问题,需要禁用SELinux并重新启动服务器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.