当auth_request使用的后端代理返回与401或403不同的错误代码时,nginx返回500错误代码。 ngx_http_auth_request_module模块(1.5.4+)根据子请求的结果实现客户端授权。 如果子请求返回2xx响应码,则允许访问。 如果返回401或403,则访问被拒绝,并显示相应的错误代码。 子请求返回的任何其他响应代码都被认为是错误的。 有没有办法让nginx从后端返回状态码而不是500?
我已经在我的ubuntu 16.04服务器上安装了nginx,php7.0-fpm和mysql。 一切工作正常但是它不加载phpmyadmin的设置页面。 下面是我的phpmyadmin nginx块。 location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+\.php)$ { try_files $uri =404; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/run/php/php7.0-fpm.sock; include fastcgi_params; } } 以下是我的nginx访问日志 /usr/share# tail -f /var/log/nginx/access.log 127.0.0.1 – – [15/Oct/2016:17:13:06 +0530] "GET /phpmyadmin/setup/index.php HTTP/1.1" 200 31 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" 127.0.0.1 – […]
这非常奇怪,我无法理解它。 我已经build立了一个nginx服务器来反向代理一个docker容器。 Nginx似乎能够服务一些页面,但不能服务于子目录,或者它可能无法提供dynamic内容。 我不完全确定这里发生了什么事情。 例如,我试图用以下configuration来反向代理activemqpipe理控制台,但似乎无法为子目录提供服务: server { listen 8162; server_name dockerdev1.site.com; ssl on; ssl_certificate /var/certificates/cert.com.crt; ssl_certificate_key /var/certificates/cert.com.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES"; ssl_prefer_server_ciphers on; location / { include /etc/nginx/mime.types; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass https://dockerdev1.site.com:11113; try_files $uri $uri/ =404; } }
我尝试增加我的服务器可以处理的并发连接数。 $uname -a Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u2 (2016-10-19) x86_64 GNU/Linux $ulimit -Sn 65536 $ulimit -Hn 65536 Nginx的configuration有以下几行: worker_processes 4; # or 8 worker_rlimit_nofile 60000; events { worker_connections 1024; } 还有一个困(无限睡觉)通过上游使用的python asyncio HTTP后端。 经过几秒钟的负载testing: 2016/11/03 05:13:44 [alert] 15#15: 1024 worker_connections are not enough 2016/11/03 05:13:44 [alert] 15#15: 1024 worker_connections are not enough 而 […]
我有一个以下的configuration: <client> <ssl nginx> <80 nginx> <laravel> laravel有一个名为asset()的方法,它应该检测模式并输出正确的url。 但它没有,我问在stackoverflow的问题 – 但它清楚这是不是PHP的问题,但与服务器的东西。 我的直觉是<ssl nginx>没有把一些重要的信息传递给<80 nginx> 。 我可以添加一些<80 nginx>虚拟主机configuration,以便它认为请求来自https ? (客户端来自https,但laravel没有看到它只看到<80 nginx> )。 我试图添加proxy_set_header X-Forwarded-Proto https到虚拟主机configuration,但它没有改变任何东西。 <80 nginx> config:
接近实时也没关系,我想可以通过不断parsing访问日志,并显示实时状态,如大多数请求的文件,顶级远程IP。 我听说过这些工具,但不记得它的名字。 任何人都知道?
我使用nginx和proxy_cache来caching一些页面,我已经设置了一个单独的刷新位置块来刷新一个特定的caching条目。 我已经testing了这一点,它为刷新工作正常。 但是它也caching了set-cookie头(我使用的框架,Symfony,即使没有login也总是为新用户创build一个新的会话cookie)。 我search了一下,显然proxy_hide_header应该帮助我,但它只隐藏返回给客户端的最终响应头,头仍然被caching。 我也尝试了其他标题,并有相同的结果。 我也尝试使用headers_more_module(more_clear_headers),但这也没有帮助。 有没有人知道这里有什么问题,或有别的我想要做的? 我正在使用nginx 1.11.2,这是configuration: location ~ /refresh(/.*) { allow 127.0.0.1; deny all; rewrite ^/refresh?(/.*)$ $1 break; proxy_hide_header "Set-Cookie"; proxy_ignore_headers "Set-Cookie" "Vary"; proxy_cache FOS_CACHE; proxy_pass http://localhost:8080; proxy_set_header Host $host; proxy_cache_key $uri$is_args$args; proxy_cache_valid 200 1m; proxy_cache_bypass 1; access_log /var/log/nginx/cache_refresh.log cache_info; } 谢谢
我只需要启用客户端证书validation,仅用于来自我们内部网之外的请求,而不validation来自例如192.168.0.0/24的请求。 我试图使用geo模块来定义内部子网的variables。 在http上下文中: geo $intranet { default 0; 192.168.0.0/24 1; } 在server环境中 if ($intranet != 1) { ssl_verify_client on; } 但是在if语句中使用ssl_verify_client指令是不可能的。 我收到一个错误: “ssl_verify_client”指令在这里是不允许的 有没有其他的方法来做到这一点?
我的nginxconfiguration有两个redirect规则: HTTP到HTTPS if ($http_x_forwarded_proto = "http") { return 301 https://$server_name$request_uri; } WWW到非WWW server_name www.alphainvesting.co.il; return 301 https://alphainvesting.co.il$request_uri; 除非用户访问http://www.alphainvesting.co.il ,否则一切都很好。 然后他们被redirect到https://alphainvesting.co.il/ *(当然返回404错误)。 值得一提的是我正在使用Cloudflare,但是我没有页面规则。
AWS(EC2 t2.nano)上运行nginx服务器的VPS非常小。 虽然有时一个sudo service nginx reload或nginx -t快速,大部分时间是非常慢(> 60秒),没有任何负载的服务器上。 有大约10个服务器块被定义为代理服务器,其中启用了ssl。 nginx-t -v没有给出任何线索,为什么这么慢,我在日志中找不到任何东西。 在此期间,RAM和CPU使用率相当低。 我怎么能调查是什么让重新加载nginx缓慢,什么是常见的东西,我可以找的? DNSparsing? 我的上游都被定义为例如 upstream ent-pbmcom { ip_hash; # for sticky sessions server 10.0.2.52:8080; } … server { … location / { add_header X-Block "ent-pbmcom"; add_header X-Upstream $upstream_addr; add_header X-Requested-Host '$host'; proxy_pass http://ent-pbmcom; proxy_set_header X-Real-IP $remote_addr; # http://wiki.nginx.org/HttpProxyModule proxy_set_header Host $host; # pass the […]