Articles of nginx

Nginx使用另一个端口而不是tcp 80和443

Rkhunter表明,nginx使用了两个UDP端口,而不是80和443,这些端口当然是启用的,但不是那些显示为隐藏端口的: [12:56:58] Checking for hidden ports [ Warning ] [12:56:58] Warning: Hidden ports found: [12:56:58] Port number: UDP:38885 is being used by /usr/sbin/nginx [12:56:58] Port number: UDP:41551 is being used by /usr/sbin/nginx 但问题是, netstat -tulpen不显示这个端口: tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 106 5680 953/mysqld tcp 0 0 127.0.0.1:139 0.0.0.0:* LISTEN 0 5679 1165/smbd tcp 0 […]

NGINX / FPM Fastcgivariables到特定的文件

为什么不能设置fastcgi_ignore_client_abort on; 只为1个文件工作,如: if ($uri ~* /test.php) { fastcgi_ignore_client_abort on; } Nginx说[emerg] "fastcgi_ignore_client_abort" directive is not allowed here 一般来说,如何编写特定的fastcgivariables只能在特定的文件上工作?

连接()到unix:/tmp/php-fpm.sock失败(2:没有这样的文件或目录)

在我的stream浪箱子里,分机7,我安装了php7.0.3和nginx 1.9.12。 PHPconfigurationwww.conf。 这个文件在/usr/local/php/etc/php-fpm.d/目录下,它的configuration就像这样 user = www group = www ;listen = /tmp/php-fpm.sock listen = 127.0.0.1:9000 listen.owner = www listen.group = www 和nginxconfiguration。 / usr / local / nginx / conf / vhost /目录下的文件vm.demo.com.conf。 它的configuration是这样的 server { listen 80; server_name vm.demo.com; index index.html index.htm index.php; root /data/wwwroot/demo; location / { if (-f $request_filename/index.html){ rewrite (.*) […]

基于源IP的Nginx TCPstream路由

我已将nginxconfiguration为TCP(非http)stream的反向代理。 我想对特定的源IP地址应用不同的路由 – 可以这样做,以及如何? 我知道使用if伪指令的http模块的推荐,但似乎不适用于这些stream。 现有configuration: stream { server { listen 8000; proxy_pass staging; } } upstream staging { server 1.2.3.4:8000; } 期望的configuration(不工作): stream { server { listen 8000; proxy_pass staging1; if ( $remote_addr ~* 4.5.6.7 ) { proxy_pass staging2; } } } upstream staging1 { server 1.2.3.4:8000; } upstream staging2 { server 1.2.3.44:8000; } […]

Nginx提供静态PHP文件

虽然试图实现缓慢的Wordpress网站的一些caching – 我已经在NGINX级别启用cachig。 然而,它似乎是坚持一个渲染文件,并不想放弃。 这不是在caching中,我试着恢复一切,禁用SendFileclosures,但Nginx仍然希望从5天前提供一个陈旧的文件。 我已经删除了Nginx,重新安装它,重新构build它,没有任何东西。 有什么想法吗? user www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile off; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # Logging Settings […]

如何使用NGINX模板?

有没有办法在nginx模板? 例如,如果我有这样一个文件: {header} <h1>This is a header</h1> This is not a header {footer} 然后用NGINXreplace{header} ,比如说: <!DOCTYPE html> <html> <head><title>This is a title</title></head> <body> 和{footer}有类似的东西。 这样做的目的是为了能够在html文件之间共享代码。 这是可能的nginx,或者我将不得不使用反向代理到不同的服务器程序,可以做模板?

Nginx wp-admin上传时间

我按照说明设置了Nginx,一切正常,但是我的wp-admin正在返回504错误( upstream timeout )。 一切工作正常,所有重写等 我已经试过缩放它,没有caching等基本知识,但仍然没有。 fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=MYAPP:100m inactive=60m; fastcgi_cache_key "$scheme$request_method$host$request_uri"; server { listen 82 default_server; listen [::]:82 default_server ipv6only=on; root /mnt/wpmount/nen; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { if ($args ~* "^s=(.*)$") { return 301 /search/$1; } #try_files $uri $uri/ /index.php?q=$uri&$args; try_files $uri $uri/ […]

基于nginx中的条件(HTTP方法),我可以绕过try_files吗?

我有nginx代理到php-fpm与以下configuration: location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /vol/app/www/$fastcgi_script_name; include fastcgi_params; } 一切都很好,直到一个DELETE请求进来,如: DELETE /?file&path=foo 发生这种情况时,nginx返回一个405(不允许的方法),并且不会将请求代理到php-fpm。 有没有办法绕过try_files指令,当它是一个DELETE请求,只是代理?

Nginx反向代理导致文件下载需要花费过多时间才能启动

概观 我的networking应用程序允许用户通过我的服务器上传存储在s3上的文件。 当用户请求文件时,我的Web服务器从s3中检索它,然后将其发送到客户端。 我最近部署了一个负载均衡器,使我目前的设置如下: 注意目前我只有一个Web服务器来简化debugging。 初始问题 部署负载平衡器后,我发现大型文件(大于4MB左右)的下载会在60秒后504网关超时失败。 我查看了网站的负载均衡器nginx错误日志,我看到了一些条目,如: [error] 11770#11770: *40 upstream timed out (110: Connection timed out) while reading response header from upstream, client: XXXX, … 当我看到网站服务器nginx错误日志为网站,我看到了类似的条目: [error] 6632#6632: *41 upstream timed out (110: Connection timed out) while reading response header from upstream, client: … [error] 6632#6632: *85 upstream timed out (110: Connection timed […]

nginx默认SSL SNI主机将覆盖SSL协议

我使用SSL(基于SNI)设置了nginx。 我第一次服务vHost使用 server { … listen 443 ssl; server_name host1; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; …. 在其他的虚拟主机上,我想要更严格,只允许TLSv1.2 server { … listen 443 ssl; server_name host2; ssl_protocols TLSv1.2; …. 但是,无论我在除了第一个主机configuration的所有主机configuration中指定,它们都不起作用。 发生的唯一更改是当我更改第一个虚拟主机。 所以host2结束了: TLSv1 TLSv1.1 TLSv1.2 它反过来也是相反的: 只在第一个虚拟主机中指定TLSv1.2 在即将到来的虚拟主机中指定所有协议 结果是,所有的虚拟主机只使用TLSv1.2 在不同的SSL SNI虚拟主机上使用不同的协议是不可能的?