Gor*_*gor 5 http nginx https redirect jenkins
我\xe2\x80\x99m 在 Nginx 后面运行 Jenkins,并使用 Let\xe2\x80\x99s 加密 SSL 证书。如果我通过访问该网站https://jenkins.mydomain.de/
,一切正常。但是当我通过 访问它时http://jenkins.mydomain.de/
,Firefox 说 \xe2\x80\x9cConnection was Reset.\xe2\x80\x9d 并且curl 说 \xe2\x80\x9c来自服务器的空回复\xe2\x80\x9d
我该如何调试这个?我真的不知道在哪里寻找问题。nginx 日志 don\xe2\x80\x99t 包含任何有关它的信息。我怀疑下面配置中有关端口 80 的部分因其他指令而无效,但我不\xe2\x80\x99 不知道如何调查它。
\n\n$ curl -svL http://jenkins.mydomain.de/\n* Hostname was NOT found in DNS cache\n* Trying my.ip.add.ress...\n* Connected to jenkins.mydomain.de (my.ip.add.ress) port 80 (#0)\n> GET / HTTP/1.1\n> User-Agent: curl/7.38.0\n> Host: jenkins.mydomain.de\n> Accept: */*\n> \n* Empty reply from server\n* Connection #0 to host jenkins.mydomain.de left intact\n
Run Code Online (Sandbox Code Playgroud)\n\n当使用 telnet 与服务器通信时,只要我按一次 return (即之后GET / HTTP/1.1
),连接就会关闭。
尽管 Firefox\xe2\x80\x99t 的 SSL 证书没有问题,但curl 却有:
\n\n$ curl -svL https://jenkins.mydomain.de/\n* Hostname was NOT found in DNS cache\n* Trying my.ip.add.ress...\n* Connected to jenkins.mydomain.de (my.ip.add.ress) port 443 (#0)\n* successfully set certificate verify locations:\n* CAfile: none\n CApath: /etc/ssl/certs\n* SSLv3, TLS handshake, Client hello (1):\n} [data not shown]\n* SSLv3, TLS handshake, Server hello (2):\n{ [data not shown]\n* SSLv3, TLS handshake, CERT (11):\n{ [data not shown]\n* SSLv3, TLS alert, Server hello (2):\n} [data not shown]\n* SSL certificate problem: unable to get local issuer certificate\n* Closing connection 0\n* SSLv3, TLS alert, Client hello (1):\n} [data not shown]\n
Run Code Online (Sandbox Code Playgroud)\n\n我的 Nginx 配置:
\n\nupstream jenkins {\n server localhost:8080 fail_timeout=0;\n}\n\nserver {\n listen 80 default;\n server_name jenkins.mydomain.de;\n return 301 https://$server_name$request_uri;\n # Replacing $server_name with $host does not work either.\n}\n\nserver {\n listen 443 default ssl;\n server_name jenkins.mydomain.de;\n\n ssl on;\n ssl_certificate /etc/letsencrypt/live/jenkins.mydomain.de/cert.pem;\n ssl_certificate_key /etc/letsencrypt/live/jenkins.mydomain.de/privkey.pem;\n\n ssl_ciphers HIGH:!ADH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;\n ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;\n ssl_prefer_server_ciphers on;\n ssl_session_timeout 5m;\n ssl_session_cache builtin:1000 shared:SSL:10m;\n\n location / {\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header X-Forwarded-Proto $scheme;\n\n proxy_redirect http://localhost:8080 https://$server_name;\n proxy_pass https://jenkins;\n }\n}\n
Run Code Online (Sandbox Code Playgroud)\n\nNginx 正在监听 80 端口:
\n\ntcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3895/nginx \ntcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1048/sshd \ntcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 3895/nginx \ntcp6 0 0 :::41117 :::* LISTEN 19911/java \ntcp6 0 0 :::8080 :::* LISTEN 19911/java \ntcp6 0 0 :::22 :::* LISTEN 1048/sshd \ntcp6 0 0 :::49208 :::* LISTEN 19911/java\n
Run Code Online (Sandbox Code Playgroud)\n
使用server
与您相同的块进行端口 80 和 301 重定向,它在我的设置中与 Jenkins 一起工作(我不认为应用程序后端有任何影响,但只是为了确定)。我遇到的问题是防火墙未打开端口 80。您应该验证自己的防火墙。
归档时间: |
|
查看次数: |
3134 次 |
最近记录: |