AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1042697
Accepted
Lewis Morris
Lewis Morris
Asked: 2020-11-17 00:59:17 +0800 CST2020-11-17 00:59:17 +0800 CST 2020-11-17 00:59:17 +0800 CST

导航到 www.domain.com 时,nginx 没有显示正确的页面,当只是 domain.com

  • 772

我正在尝试在 ubuntu 上部署 nginx/gunicorn/flask,当我导航到“domain.com”时,一切似乎都在工作,但是当我转到“www.domain.com”时,我得到了 nginx 的默认启动画面。

nginx的设置如下。

server {
 server_name thecomputermade.me www.thecomputermade.me;
location / {
include proxy_params;
proxy_pass http://unix:/home/ubuntu/imageRate/imageRate.sock;
}

listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/thecomputermade.me/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/thecomputermade.me/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot



}
server {
if ($host = thecomputermade.me) {
return 301 https://$host$request_uri;
} # managed by Certbot


listen 80;
server_name thecomputermade.me;
return 404; # managed by Certbot

}

当我跑步时,systemctl status nginx我得到以下信息。

 nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2020-11-16 08:54:05 UTC; 999ms ago
       Docs: man:nginx(8)
    Process: 1430 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 1442 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 1443 (nginx)
      Tasks: 2 (limit: 560)
     Memory: 2.9M
     CGroup: /system.slice/nginx.service
             ├─1443 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             └─1444 nginx: worker process

Nov 16 08:54:05 ip-172-26-6-186 systemd[1]: Starting A high performance web server and a reverse proxy server...
Nov 16 08:54:05 ip-172-26-6-186 nginx[1430]: nginx: [warn] conflicting server name "www.thecomputermade.me" on 0.0.0.0:443, ignored
Nov 16 08:54:05 ip-172-26-6-186 nginx[1442]: nginx: [warn] conflicting server name "www.thecomputermade.me" on 0.0.0.0:443, ignored
Nov 16 08:54:05 ip-172-26-6-186 systemd[1]: Started A high performance web server and a reverse proxy server.

请注意它显示冲突服务器名称的行...

我已经在 nginx 配置中尝试了 computermade.me:

  • “thecomputermade.me”按预期工作,但“www.thecomputermade.me”再次导航到 nginx 的默认启动屏幕。

当我在配置中仅添加“www.thecomputermade.me”时:

  • 两个地址都导航默认启动画面,我收到冲突的服务器名称警告。

有谁知道我需要做什么?

ubuntu nginx gunicorn amazon-lightsail
  • 1 1 个回答
  • 47 Views

1 个回答

  • Voted
  1. Best Answer
    Lewis Morris
    2020-11-17T01:21:22+08:002020-11-17T01:21:22+08:00

    好的,所以我已经解决了。

    首先,我运行 sudo grep -r www.thecomputermade.me /etc/nginx它显示了对该域的多个引用。

    这意味着,正如错误所说。服务器名称存在冲突。

    为什么会这样?

    原来 certbot 将一些数据添加到/etc/nginix/sites-available.

    为了解决这个问题,我在默认配置文件中注释掉了所有与“www.thecomputermade.me”相关的行,嘿,它确实有效。

    希望这对将来的其他人有所帮助。

    • 0

相关问题

  • 无法通过 Ubuntu VPN 访问外部网络

  • ubuntu apt-get upgrade - 如何在 shell 中单击确定?

  • VirtualBox 上 Ubuntu 的访客优化技巧 [关闭]

  • 外部硬盘上的 virtualbox 虚拟硬盘驱动器(Vista 主机上的 ubuntu 客户机)

  • 如何在 Ubuntu 上挂载 LVM 分区?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve