运行时我正在尝试运行我的网站
uwsgi --socket 0.0.0.0:8080 --protocol=http --chdir /opt/virtualenv/landivarpj/ --wsgi-file /opt/virtualenv/landivarpj/landivarpj/wsgi.py
我可以正常访问192.xxx.xxx.xxx:8080,并显示我的测试文字, 但是如果我尝试进入192.xxx.xxx.xxx,我只会看到一个nginx欢迎页面, 如果我尝试进入我的域名www.xxxxxxxx.com,那么它根本不起作用。
在我的项目文件夹(opt / virtualenv / landivarpj)中,我有一个带有
的uswgi_params文件uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REQUEST_SCHEME $scheme;
uwsgi_param HTTPS $https if_not_empty;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;
然后在(opt / virtualenv / landivarpj / landivarpj)中,wsgi.py是
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "landivarpj.settings")
application = get_wsgi_application()
在etc / nginx / sites-available中有drlandivar.conf
upstream django {
server 192.xxx.xxx.xxx:8080; # for a web port socket (we'll use this first)
}
server {
listen 80;
server_name drlandivar.com www.drlandivar.com;
charset utf-8;
client_max_body_size 75M; # adjust to taste
location /media {
alias /opt/virtualenv/landivarpj/media;
}
location /static {
alias /opt/virtualenv/landivarpj/static;
}
location / {
uwsgi_pass django;
include /opt/virtualenv/landivarpj/uwsgi_params;
}
}
网站可用和网站启用链接
我做错了什么,为什么它可以在192.xxx.xxx.xxx:8080上工作 但没有使用域和Nginx
*****根据nginx / availables-site / drlandivar.conf上的建议进行新编辑
upstream django {
server 192.254.145.207:8080;
}
server {
listen 80;
server_name drlandivar.com www.drlandivar.com;
charset utf-8;
client_max_body_size 75M; # adjust to taste
location /media {
alias /opt/virtualenv/landivarpj/media;
}
location /static {
alias /opt/virtualenv/landivarpj/static;
}
location / {
proxy_pass http://django;
}
}
它仍然给我同样的问题页面,仅加载了tr.192.xxx.xxx.xxx:8080而不是drlandivar.com 请帮助
答案 0 :(得分:1)
您需要改为proxy_pass
。以下配置可以解决问题。
upstream django {
server 192.254.145.207:8080;
}
server {
...
location / {
proxy_pass http://django;
}
}
答案 1 :(得分:0)
将您的示例与我的工作示例进行比较,有一件事情很突出。试试
...
location / {
include uwsgi_params;
proxy_pass http://django;
}
在您的uwsgi调用中添加--logto /var/log/uwsgi/uwsgi.log
(在创建/var/log/uswgi
并将其写入uwsgi进程之后)可能会带来更多启示。