Tom*_*Tom 3 ssl nginx mongodb node.js http2
我正在开发一个角度为4.1.0的MEAN项目.
在我的localhost上,一切正常,没有错误.但是,当我部署到服务器时,检索具有8个以上问题 - 答案对的用户会导致在角度的http模块触发的xhr请求上出现net :: ERR_CONNECTION_CLOSED错误.
我托管的数字海洋小滴使用nginx反向代理并使用letsencrypt SSL证书.我试过了:
client_max_body_size至20M在nginx的配置文件large_client_header_buffers'size'增加到128knginx配置文件中其他重要事实:
GET请求qapairs?jwt=ey../var/log/nginx/error.log显示的失败请求/var/log/nginx/access.log如下:
89.15.159.19 - - [08/May/2017:14:25:53 +0000] "-" 400 0 "-" "-"
89.15.159.19 - - [08/May/2017:14:25:53 +0000] "-" 400 0 "-" "-"
Run Code Online (Sandbox Code Playgroud)请指出我可能的方向.
登录到只有7个问题答案对的帐户后

然后,在转到mlab.com并手动将另一个问题答案对添加到同一帐户然后刷新页面(注意现在的问题数量为8)

最后,登录和退出同一帐户后(注意xhr请求qapairs?jwt=ey...返回失败状态)

在/ etc/nginx的/启用的站点 - /默认
Run Code Online (Sandbox Code Playgroud)# HTTP — redirect all traffic to HTTPS server { listen 80; listen [::]:80 default_server ipv6only=on; return 301 https://$host$request_uri; } # etc # HTTPS ^ ^ proxy all requests to the Node app server { # Enable HTTP/2 listen 443 ssl http2; listen [::]:443 ssl http2; server_name subdomain.example.com; # Use the Let ^ ^ s Encrypt certificates ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # Include the SSL configuration from cipherli.st include snippets/ssl-params.conf; # Increase allowed URL length large_client_header_buffers 4 128k; # Increase max body size client_max_body_size 20M; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_pass http://subdomain.example.com:3001/; proxy_ssl_session_reuse off; proxy_set_header Host $http_host; proxy_cache_bypass $http_upgrade; proxy_redirect off; } }
QA-pairs.service.ts
错误正在
getQAPairs函数中捕获.传递给回调的catch函数ProgressEvent对象具有type的属性error,eventPhase的2.Run Code Online (Sandbox Code Playgroud)@Injectable() export class QaPairsService { /* etc */ getQAPairs () { const jwt = localStorage.getItem('jwt') ? `?jwt=${localStorage.getItem('jwt')}` : '' return this.http.get(this.qapairsUrl + jwt) .map(response => { this.qapairs = response.json().map((qapair: IQAPair) => new QAPair(qapair)) this.qapairsChanged.emit(this.qapairs) return this.qapairs }) .catch( (error: any) => { error = error.json() this.errorsService.handleError(error) return Observable.throw(error) } ) } /* etc */ }
在/ etc/nginx的/启用的站点 - /默认
# other code here server { # other code here # Increase http2 max sizes http2_max_field_size 64k; http2_max_header_size 64k; }
我发现这很难调试的原因是因为有
没有提到请求
/var/log/nginx/error.log
而且我没有意识到nginx能够通过其日志记录更加冗长(duh)
所以改成后/etc/nginx/sites-enabled/default包括
server {
error_log /var/log/nginx/error.log info;
}
Run Code Online (Sandbox Code Playgroud)
我看见
2017/05/08 16:17:04 [info] 3037#3037: *9 client exceeded http2_max_field_size limit while processing HTTP/2 connection, client: 89.15.159.19, server: 0.0.0.0:443
Run Code Online (Sandbox Code Playgroud)
这是我需要的错误信息.
| 归档时间: |
|
| 查看次数: |
1699 次 |
| 最近记录: |