Webserver Nginx端口转发,使用uwsgi瓶子
我有以下问题: 使用端口8770调用我的服务器效果很好;不使用它进行调用会产生以下结果:Webserver Nginx端口转发,使用uwsgi瓶子,webserver,port,uwsgi,forwarding,Webserver,Port,Uwsgi,Forwarding,我有以下问题: 使用端口8770调用我的服务器效果很好;不使用它进行调用会产生以下结果: root@server1:~# wget http://127.0.0.1 --2018-06-20 17:14:03-- http://127.0.0.1/ Connecting to 127.0.0.1:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://127.0.0.1/171219
root@server1:~# wget http://127.0.0.1
--2018-06-20 17:14:03-- http://127.0.0.1/
Connecting to 127.0.0.1:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://127.0.0.1/17121985 [following]
--2018-06-20 17:14:03-- http://127.0.0.1/17121985
Reusing existing connection to 127.0.0.1:80.
HTTP request sent, awaiting response... 404 Not Found
2018-06-20 17:14:03 ERROR 404: Not Found.
这基本上是说,我可以与服务器对话,但我没有收到发送的响应
有什么建议吗
我的瓶子应用程序正在运行:
@route('/')
def init(db):
# check if user_id is set
if request.get_cookie("user_id"):
user_id = request.get_cookie("user_id")
redirect('/' + str(user_id))
if __name__ == "__main__":
run(app=app, host='127.0.0.1', port=8770, debug=True, quiet=True)
Nginx配置:
root@server1:~# cat /etc/nginx/conf.d/bottle.conf
upstream _bottle {
server unix:/run/uwsgi/app/bottle/socket;
}
server {
listen [::]:80;
listen 80;
listen 8770;
server_name _;
root /var/www/bottle;
location / {
proxy_pass http://127.0.0.1:8770;
try_files $uri @uwsgi;
}
location @uwsgi {
proxy_pass http://127.0.0.1:8770;
include uwsgi_params;
uwsgi_pass _bottle;
}
}
谢谢大家! 非常简单:
只需添加服务器名称处的dns或服务器的IP即可
我添加了这两个选项,解决了502坏网关问题
Nginx的瓶子.conf:
upstream _bottle {
server unix:/run/uwsgi/app/bottle/socket;
}
server {
listen [::]:80;
listen 80;
server_name 139.59.212.77 my-domain.org;
root /var/www/bottle;
location / {
try_files $uri @uwsgi;
uwsgi_pass _bottle;
}
location @uwsgi {
proxy_pass http://127.0.0.1:8770;
include uwsgi_params;
uwsgi_pass _bottle;
}
location /css {
alias /var/www/bottle/css;
}
location /js {
alias /var/www/bottle/js;
}
}