这种情况有点难以描述。我使用nginx和uwsgi在我的VPS上部署我的Django博客,它运行良好,但我只能使用我的IP来访问应用程序,如何使用我的域名而不用www来设置我的应用程序?我设置server_name breakwire.me并设置A记录HOST为'@',指向我的VPS的IP,但如果我访问breakwire.me,我只能看到
“欢迎来到nginx”
这是我的nginx conf
# my_blog__nginx.conf
# configuration of the server
server {
the port your site will be served on
listen 106.186.29.228:8000;
# the domain name it will serve for
server_name breakwire.me; # substitute your machine's IP address or FQDN
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# logs
access_log /home/chen/DjangoProjects/my_blog/logs/access.log;
error_log /home/chen/DjangoProjects/my_blog/logs/error.log;
# Django media
location /media {
alias /home/chen/DjangoProjects/my_blog/media; # your Django project's media files - amend as required
}
location /static {
alias /home/chen/DjangoProjects/my_blog/static; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass 106.186.29.228:8001;
include /home/chen/DjangoProjects/my_blog/uwsgi_params; # the uwsgi_params file you installed
}
}
答案 0 :(得分:1)
更改
听106.186.29.228:8000
到
听106.186.29.228
或:106.186.29.228:80
浏览器始终在端口80上连接.nginx中的虚拟服务器正在侦听端口8000,因此如果您尝试使用http://breakwire.me:8000/打开网站 它的工作原理是因为你在listen指令中将端口设置为8000。