gpt4 book ai didi

java - 将 Nginx 移动为使用 HTTPS 的问题无法解决(3 : Host not found)

转载 作者:行者123 更新时间:2023-12-02 03:32:13 24 4
gpt4 key购买 nike

所以我有以下 nginx 配置:

events {
worker_connections 1024;
}

http {

server {
listen 80 default_server;
charset utf-8;
access_log off;
try_files $uri $uri/ =404;
#use google as dns
resolver 8.8.8.8;
server_name www.workaround.xyz workaround.xyz;
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
charset utf-8;
access_log off;
try_files $uri $uri/ =404;
#use google as dns
resolver 8.8.8.8;
server_name www.workaround.xyz workaround.xyz;

ssl_certificate /etc/letsencrypt/live/workaround.xyz-0001/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/workaround.xyz-0001/privkey.pem;

location / {
proxy_pass $scheme://workaround:8085/;
}

location ^~ {
proxy_pass $scheme://workaround:8085/$request_uri;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
expires 30d;
}
}


}

这是我尝试将内容转移到使用 HTTPS,并支持 www.域的前缀。在这次尝试中我得到:

2019/07/03 20:55:38 [error] 6#6: *3 workaround could not be resolved (3: Host not found), client: XXXXX_SOME IP_XXXX, server: www.workaround.xyz, request: "GET / HTTP/1.1", host: "www.workaround.xyz"

尝试了多种不同的方法,每次弹出无法解析的变体时,任何人都知道我做错了什么以及我可以改进/修复什么以使其与 https 正常工作?

工作 HTTP 版本是这样的:

events {
worker_connections 1024;
}

http {

server {
listen 80;
charset utf-8;
access_log off;
try_files $uri $uri/ =404;

location / {
proxy_pass http://workaround:8085/;
}

location ^~ {
proxy_pass $scheme://workaround:8085/$request_uri;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
expires 30d;
}
}


}

最佳答案

明白了。

events {
worker_connections 1024;
}

http {

server {
listen 80 default_server;
charset utf-8;
access_log off;
try_files $uri $uri/ =404;
#use google as dns
resolver 8.8.8.8;
server_name workaround.xyz;
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
charset utf-8;
access_log off;
try_files $uri $uri/ =404;
server_name workaround.xyz;

ssl_certificate /etc/letsencrypt/live/workaround.xyz-0001/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/workaround.xyz-0001/privkey.pem;

if ($host = www.$server_name) {
rewrite ^(.*) https://$server_name$request_uri? permanent;
}

location / {
proxy_pass http://workaround:8085/;
}

location ^~ {
proxy_pass http://workaround:8085/$request_uri;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
expires 30d;
}
}


}

关于java - 将 Nginx 移动为使用 HTTPS 的问题无法解决(3 : Host not found),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56877906/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com