nginx不会将httpredirect到https

我有一个nginx docker,运行着多个 site-config文件。

其中之一就是所有http连接的一般redirecthttps

 server { listen 80; server_name *.example.com example.com; return 301 https://$host$request_uri; } 

所有其他的site-config文件是为我的其他docker/服务如Nextcloud和Plex。

每当我把例如https://plex.example.cominput到我select的浏览器(甚至是IE)中时,它都会显示正确的网页,并显示一个ssh-connection。

但是,inputhttp://plex.example.com只会返回一个空白页面,在这种情况下不会将我redirect到Plex。

任何人有一个想法?

PS:默认的site-config文件是空的。 但是由于这样的事实,所有的服务/docker工人的site-configs工作,我猜测,redirect在一个额外的文件不会是问题。

PPS:这是一个访问日志的例子。 错误日志是空的(超过3个月没有新的条目)。 日志是通过https访问我的plex服务器。 通过http访问任何内容都不会创build日志条目。

 192.168.0.2 - - [13/Nov/2017:21:53:02 +0100] "GET / HTTP/1.1" 401 157 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko" 192.168.0.2 - - [13/Nov/2017:21:53:02 +0100] "GET /web/index.html HTTP/1.1" 200 1650 "https://plex.example.com/" "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko" 192.168.0.2 - - [13/Nov/2017:21:53:02 +0100] "GET /web/main.8883144fb7acc2430ef50eda6c1a41c8.css HTTP/1.1" 200 764765 "https://plex.example.com/web/index.html" "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko" 192.168.0.2 - - [13/Nov/2017:21:53:02 +0100] "GET /web/main.v3.3a6aa4986f36a5810792d74118deda14.css HTTP/1.1" 200 214735 "https://plex.example.com/web/index.html" "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko" 192.168.0.2 - - [13/Nov/2017:21:53:02 +0100] "GET /web/js/vendors-1-d55a6a600958df7159e4-plex-3.20.7-d87fe16.js HTTP/1.1" 200 1148751 "https://plex.example.com/web/index.html" "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko" 192.168.0.2 - - [13/Nov/2017:21:53:02 +0100] "GET /web/js/main-0-2a819e76950d4ad197a8-plex-3.20.7-d87fe16.js HTTP/1.1" 200 3259450 "https://plex.example.com/web/index.html" "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko" 192.168.0.2 - - [13/Nov/2017:21:53:02 +0100] "GET /web/common/img/backgrounds/preset-dark.5b95c8c24aab87067b69bca7ae11759a.png HTTP/1.1" 200 40582 "https://plex.example.com/web/index.html" "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko" 192.168.0.2 - - [13/Nov/2017:21:53:02 +0100] "GET /web/translations/de.json HTTP/1.1" 200 128137 "https://plex.example.com/web/index.html" "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko" 192.168.0.2 - - [13/Nov/2017:21:53:02 +0100] "GET /web/common/img/backgrounds/noise.0e9cf16a17adb19690cd31312cdaa809.png HTTP/1.1" 200 94668 "https://plex.example.com/web/index.html" "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko" 192.168.0.2 - - [13/Nov/2017:21:53:03 +0100] "GET /web/favicon.ico HTTP/1.1" 200 5430 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; Trident/7.0; rv:11.0) like Gecko" 192.168.0.2 - - [13/Nov/2017:21:53:03 +0100] "GET /?X-Plex-Product=Plex%20Web&X-Plex-Version=3.20.7&X-Plex-Client-Identifier=yi606rcck7j3x9lx3wafhzgx&X-Plex-Platform=Internet%20Explorer&X-Plex-Platform-Version=11.0&X-Plex-Device=Windows&X-Plex-Device-Name=Plex%20Web%20%28Internet%20Explorer%29&X-Plex-Device-Screen-Resolution=1149x738%2C2560x1440 HTTP/1.1" 401 157 "https://plex.example.com/web/index.html" "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko" 192.168.0.2 - - [13/Nov/2017:21:53:03 +0100] "GET /identity?X-Plex-Product=Plex%20Web&X-Plex-Version=3.20.7&X-Plex-Client-Identifier=yi606rcck7j3x9lx3wafhzgx&X-Plex-Platform=Internet%20Explorer&X-Plex-Platform-Version=11.0&X-Plex-Device=Windows&X-Plex-Device-Name=Plex%20Web%20%28Internet%20Explorer%29&X-Plex-Device-Screen-Resolution=1149x738%2C2560x1440 HTTP/1.1" 200 160 "https://plex.example.com/web/index.html" "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko" 192.168.0.2 - - [13/Nov/2017:21:53:06 +0100] "POST /index.php/heartbeat HTTP/1.1" 200 31 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" 

P3S: curl -i http://cloud.example.com/的结果curl -i http://cloud.example.com/

 HTTP/1.1 401 Unauthorized WWW-Authenticate: Basic realm='unRAID SMU' Server: emhttp Connection: close Content-Type: text/plain Content-Length: 16 401 Unauthorized 

访问日志条目:没有创build条目

curl -i https://cloud.example.com/的结果curl -i https://cloud.example.com/

 HTTP/1.1 302 Found Server: nginx/1.12.2 Date: Mon, 13 Nov 2017 21:20:39 GMT Content-Type: text/html; charset=UTF-8 Transfer-Encoding: chunked Connection: keep-alive X-Powered-By: PHP/7.1.9 Set-Cookie: oc367h1rrnkw=6033cj2p99saalb4csog6k47p5; path=/; HttpOnly Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate Pragma: no-cache Set-Cookie: oc_sessionPassphrase=SECRETPASSPHRASE; path=/; secure; HttpOnly Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-eval' 'nonce-cHlJeHJhUFhzZWJmdDdwSWVkVisrYUFPMGVVd1p1eDJXSW44TkhESE9HND06eVZ0dzFPU1p3N1d1OE1BdEhib3cxdk1obWFwMFBvSThhc0dVZnlTZ0NUMD0='; style-src 'self' 'unsafe-inline'; frame-src *; img-src * data: blob:; font-src 'self' data:; media-src *; connect-src *; object-src 'none'; base-uri 'self'; X-Frame-Options: SAMEORIGIN Set-Cookie: __Host-nc_sameSiteCookielax=true; path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=lax Set-Cookie: __Host-nc_sameSiteCookiestrict=true; path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=strict Location: https://cloud.example.com/index.php/login X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block X-Robots-Tag: none X-Download-Options: noopen X-Permitted-Cross-Domain-Policies: none Strict-Transport-Security: max-age=63072000; includeSubdomains Front-End-Https: on 

访问日志条目:

 192.168.0.2 - - [13/Nov/2017:22:24:11 +0100] "GET / HTTP/1.1" 302 5 "-" "curl/7.47.0" 

P4S netstat -natup | grep nginx的结果 netstat -natup | grep nginx

 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 305/nginx.conf tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 305/nginx.conf tcp 0 0 172.17.0.5:443 192.168.0.2:56973 ESTABLISHED 336/nginx: worker p tcp 0 0 172.17.0.5:443 192.168.0.2:56977 ESTABLISHED 336/nginx: worker p tcp 0 0 172.17.0.5:443 192.168.0.2:56981 ESTABLISHED 336/nginx: worker p tcp 0 0 172.17.0.5:443 192.168.0.2:56722 ESTABLISHED 336/nginx: worker p tcp 0 0 172.17.0.5:443 192.168.0.2:56976 ESTABLISHED 336/nginx: worker p tcp 0 0 172.17.0.5:443 192.168.0.2:56980 ESTABLISHED 336/nginx: worker p tcp 0 0 172.17.0.5:443 192.168.0.2:56971 ESTABLISHED 336/nginx: worker p tcp 0 0 172.17.0.5:443 192.168.0.2:56966 ESTABLISHED 335/nginx: worker p 

我发现了这个问题。 首先,关于我的服务器/设置:它的监视GUI默认运行在80端口,从来没有关心改变。 我所做的只是将外部端口80映射到服务器上的端口84。 84是端口let'sencrypt / nginx正在监听。

现在我的路由器最近的软件更新,它select忽略端口映射,同时访问我的局域网内的URL。 因此,我通过http请求访问服务器GUI,并得到了curl中的Access Denied错误。

我跟踪了与服务器的连接后得到了这个想法。

我可能会改变服务器GUI的端口到别的东西。 但现在我很高兴,一切都始终正常工作