我有以下问题: 用端口: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/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.
这基本上是说,我可以与服务器对话,但是我没有得到响应发送。
有什么建议吗?
我的Bottle应用程序正在运行:
@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;
}
}
谢谢!
答案 0 :(得分:0)
非常简单: 只需将dns添加到server_name或服务器的IP。
我同时添加了两者,并且我的502 Bad Gateway问题已解决。
bogin.conf用于Nginx:
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;
}
}