
nginx で理解できない問題が発生しました。
www.example.tech
正しくセットアップして電話をかけることができますexample.tech
。
survey.example.tld
ただし、リストに別のサブドメインを追加すると、他の 2 つは引き続き機能しますが、survey.example.tld
機能しなくなります。
Chrome で電話をかけようとすると、次のエラー メッセージが表示されますhttp://survey.example.tech/
。
このサイトにアクセスできません survey.example.tech にタイプミスがないか確認してください。 DNS_PROBE_FINISHED_NXDOMAIN
3 回確認したので、タイプミスはないと思います。また、www.example.tech
まだexample.tech
動作します。
nginx を使用して、リクエストを gunicorn/flask アプリに転送します。
そこで私は自分の設定を/etc/nginx/sites-enabled
$ cat /etc/nginx/sites-enabled/survey.example.tech
server {
server_name example.tech www.example.tech survey.example.tech;
location /static {
alias /opt/example.tech/my-domain-Survey-Website/static;
}
location / {
proxy_pass http://localhost:8003;
include /etc/nginx/proxy_params;
proxy_redirect off;
# Max file size allowed for upload by user. Here 1M = 1 Megabyte
client_max_body_size 1M;
# prevents warning messages when setting up let's encrypt
proxy_headers_hash_max_size 512;
proxy_headers_hash_bucket_size 128;
# Enable Websocket by adding these two options
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}
および対応するサービス/etc/systemd/system
$ cat /etc/systemd/system/gunicorn-my-domain-survey-flask.service
[Unit]
Description = gunicorn for my-domain website
After = network.target
[Service]
Environment=LOG_PATH=/opt/example.tech/example.tech-Survey-Website/gunicorn-logs
User = ubuntu
Group = ubuntu
WorkingDirectory = /opt/example.tech/example.tech-Survey-Website
ExecStart = /opt/example.tech/venv/bin/gunicorn --bind 127.0.0.1:8003 -w 1 --log-level debug --access-logfile ${LOG_PATH}/access-logfile.log --error-logfile ${LOG_PATH}/error.log --capture-output run_survey_website:app
[Install]
WantedBy = multi-user.target
これを実行すると、を除いてすべて正常に動作しますsurvey.example.tech
。
ここで何が起こっているのでしょうか? nginx でのサブドメインの設定を誤解しているのでしょうか?
答え1
nginx の設定は問題ありません。
survey.example.tech
サーバーの IP アドレスを指すDNS レコードを追加する必要があります。