Articles of nginx

Nginx – 400请求头或Cookie太大(Angular + Symfony)

我在同一台服务器上有两个项目: Symfony 3 API(api.example.com) 一个使用上面提到的API(www.example.com)的Angular 5 webapp, 两者都在同一台服务器上,每个都有一个Nginxconfiguration文件。 两者都使用HTTPS,并且在我的服务器上运行良好:Angular显示其主页,我可以在api.example.com/doc中看到API的文档,所以问题是当我想从我的API调用API的端点时Web应用程序。 在Angular应用程序中,用户可以通过Google OAuthlogin,如果用户login成功,API会向Web应用程序提供一个承载令牌。 问题出在OAuth身份validation之后,对API的第一个请求失败,出现以下错误: 400 Bad Request Request Header Or Cookie Too Large 我的JWT令牌如下所示: Bearer eyJhbGciOiJSUzI1NiJ9.eyJyb2xlcyI6WyJST0xFX1VTRVIiXSwidXNlcm5hbWUiOiIxMDU1MTc2OTEwNjQzODA2MDQ0NDgiLCJleHAiOjE1MTE1NzkyMDgsImlhdCI6MTUxMDkxMjU0Mn0.EQR-8za7LdvsdGmOrBrJnH5QZrkzObop7B_9_KsSjPAYTHV_3BwQEOgz-AJcbffNvBgGlVphsUgVzU2npp7AclrrZ1EScjjDmx7mKY4vBCRr__fL8WhMVjLEApavaGVTwG-AJBRzDOGA8DVpa9rC_Bd_ixtZtKMaZrJsqm5OjmqexbWd5GM9FJr8uO6bZnS4Xk2WnfNTIFWgkKdqMT0F4zkZMHFXJmV8BRb0JG1-ktx2Y7IK3Npk3MD02pMS2QdIikjPSUbfXaQzqVKhbpH_N-WyEgBjdRCKPMjBlYVm9uhM0rkaPDpZemawaqB0Wm_bWrDPUnlNz4xQ18xkXu-mWvXi0jNTP7ezMqDAZyxCY37S4wrUb-jBz_e_7klEsUfrUTPid63K6wBn00bQPyqyPHybQgurcKFDRPMgT0W2nfnxjssBmz_pBpCL5pJFPlAiAonq8DZxELWQW9oSLNbOxy3kF2macl2tNDY1sl88uftbIzD1hF2Hrh-xqRsgDUei-KdcxetJ_CwdYPlw48lUbeFUmYp1llX5YB3WBkMVMzDCh14fACiN0d0AHqRKiQb6dpAFcidS8NWdQb1B7ytM586r6NIjWcL9SboTemOIMu884IszccUowpd9R-eScmxQCbKKxKtkktIGxKkSz9BuGJU25oW0C1wNbzdkonlOYDQ 我没有任何关于这个问题的错误日志。 我想这是来自我的Nginxconfiguration,但我不知道它是来自web应用程序还是API Nginxconfiguration。 这是我的Webapp Nginxconfiguration文件: server { listen 80; server_name www.example.com example.com; return 301 https://www.example.com$request_uri; } server { listen 443 ssl; server_name example.com; return 301 https://www.example.com$request_uri; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; ssl_protocols […]

NGINX:使用查询string路由到特定path组件的别名中的index.php

这是传统的应用程序(Zend框架1),我们正在从Apache转移到Nginx。 我们有根据请求URI调度到特定控制器/动作的前端控制器。 需求 1. www.example.com –> /home/user/www/public/index.php 2. www.example.com/a/b –> /home/user/www/public/index.php 3. www.example.com/api –> /home/user/api/public/index.php 4. www.example.com/api/a/b –> /home/user/api/public/index.php 5. www.example.com/api/a/b?x=1 –> /home/user/api/public/index.php 当前configuration location /api { alias /home/user/api/public/; try_files $uri /api/index.php; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } } 这是什么PHP脚本收到 array ( [USER] => www-data […]

如何以及在哪里configuration使用Docker的php-fpm的pm.max_children?

在一个使用Nginx和PHP-FPM的Web应用程序中,我注意到了缓慢的时刻和分析日志,我发现这个消息不时出现: [19-Nov-2017 19:24:09] WARNING: [pool www] server reached pm.max_children setting (5), consider raising it 经过一番研究之后,我增加了php.iniconfiguration文件中的值, 停止并移除了php容器并重build它 ,因为设置为卷上的文件的设置已经生效。 分析容器中的configuration文件,它与我设置的新值相关,但是关于pm.max_children(5)的错误消息继续出现。 Here is my docker-compose.yml version: '2' services: pi_web: build: ./nginx ports: – "80:80" – "443:443" volumes: – ../src:/src – ./nginx/conf.d:/etc/nginx/conf.d – ./nginx/nginx.conf:/etc/nginx/nginx.conf – /etc/letsencrypt:/etc/letsencrypt pi_php: build: ./php volumes: – ../src:/src – ./php/config/php.ini:/usr/local/etc/php/php.ini 这是./php/config/php.ini的一个片段: pm = dynamic pm.max_children […]

如何使NGINX负载平衡服务器不代理请求?

我无法find问题的解决scheme,所以这是我的问题。 假设我有3台服务器,其中2台是上游服务器,1台是负载平衡器。 这是我的基本configuration 上游服务器 user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; gzip on; gzip_disable "msie6"; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } […]

如何301一块一块地redirect?

我会把我的博客网站(每月25万的stream量)移到一个新的域名。 我将使用HTTP 301redirect。 但是由于某些商业原因,我不应该同时redirect所有的链接。 我应该每天重复定向到50页(我有1100个链接)。 然而在这种情况下,我每天要写50个URL到nginxconfiguration文件。 即使50个网站看起来不好,拥挤的我。 我无法想象我将如何处理Nginxconfiguration文件中的700-800个URL。 所有链接包含关键字。 我该如何处理这个问题? 最佳做法是什么? 谢谢 !

用nginx反向代理来expression获取ERR_CONNECTION_REFUSED

我收到一个ERR_CONNECTION_REFUSED错误,试图将代理从nginx转换为带有SSL的socket.io服务器。 这是我的设置: 在/ var / nginx的/网站可用/默认 server { listen 80; server_name www.example.com; root /var/node/example.com/dist; index index.html; # Static build files location / { proxy_pass http://localhost:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } # socket.io location /socket.io/ { proxy_pass http://localhost:7070; proxy_http_version 1.1; proxy_set_header Host $host ; proxy_set_header X-Real-IP $remote_addr; […]

Passenger + Nginx => 502 Bad Gateway

我试图运行一个相对简单的rails应用程序(http:// www.enkiblog.com/),它有点作品。 当我使用“脚本/服务器-e生产”并连接到端口3000(但仍处于生产模式)时,注释和pipe理界面才起作用。 Nginx将在他的error.log中有这个: 2009/06/02 21:46:10 [error] 11536#0: *18 upstream prematurely closed connection while reading response header from upstream, client: 85.180.23.43, server: *.marc-seeger.de, request: "GET /admin HTTP/ 1.1", upstream: "unix:/tmp/passenger.11520/master/ helper_server.sock:", host: "www.marc-seeger.de" *** Exception NoMethodError in application (undefined method `each' for nil:NilClass) (process 14080): from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/ gems/passenger-2.2.2/lib/phusion_passenger/rack/request_handler.rb: 85:in `process_request' from /opt/ruby-enterprise-1.8.6-20090421/lib/ruby/gems/1.8/ gems/passenger-2.2.2/lib/phusion_passenger/abstract_request_handler.rb: 203:in `main_loop' […]

如何在Mac OS X上安装最新的稳定的nginx

任何人都可以提供一些有关如何安装比0.6.32 macintosh更晚的nginx? 在Linux上我使用0.7.55,所以想在Mac上有相同的。 后续工作:我意识到,我也可以像我为Linux那样从源代码构build它,这对我来说很有用。

PHP-FPM + NGINX:PHP-CGI进程在闲置一段时间后死机,然后502坏的网关和手动重启需要

我目前正在build立一个VPS(与VPS.NET),我将用它来主持一个博客和一些其他的东西。 我已经安装了nginx,并用php-fpm修补了php(5.2.8)。 所有的工作都非常棒(而且速度非常快),除了一个恼人的问题:因为现在网站没有其他的stream量,一段时间以后,它一直处于空闲状态,所有的php-cgi进程都会死掉。 只要我尝试访问网站,nginx返回一个不错的“502坏的网关”,并修复我必须手动重新启动php-fpm才能使网站再次工作。 这是为什么? 我已经看到这是一个普遍的问题,但是在空闲时间寻找解决办法的几天之后,我发现没有任何东西对我有效。 有什么build议么? 提前致谢

静态只configurationNginx的?

我试图获得一个静态的configurationnginx与try_files工作,但遇到了一些问题。 以下是我现在正在工作(但不处理目录,显示索引等)我想看看如果我可以得到一个版本与try_files工作… server { listen 80; server_name foo.com; rewrite ^ http://www.foo.com$uri permanent; } # the server directive is nginx's virtual host directive. server { # port to listen on. Can also be set to an IP:PORT listen 80; # Set the charset charset utf-8; # Set the max size for file uploads to 10Mb client_max_body_size […]