Articles of nginx

HTTP DELETE在Nginx和Application之间超时

我们正在使用HTTP DELETE面对一个非常奇怪的错误,症状是偶尔用户在浏览器中得到504(超时)错误。 请求stream经下面描述的步骤: 浏览器 – > Akamai – > AWS ELB – > Nginx – > AWS Application ELB – >应用程序 我们已经完成了请求。 我们发现,当发生错误时,请求会出现在Nginx的access.log中,但不会出现在AWS Application ELB的访问日志中。 所以Nginx是一个返回的超时,它等待60秒,然后返回408.看看访问日志和debugging日志,它看起来像Nginx代理应用程序的请求,但请求不通过。 进一步失败的请求也不会出现在Nginx服务器上的TCP Dump上。 我们收集的一些事实: 这个错误在Safari中不会发生,但偶尔会在Chrome和Firefox中发生, 在Firefox中,如果我们设置network.http.max-connections-per-server 10,问题就会消失。 任何高于(> 10)的值都会反击。 在Akamai中禁用HTTP 2可以减less问题发生的次数。 看来问题只发生在删除HTTP动词。 我们试图直接将Nginx指向应用程序实例(跳过ELB),问题依然存在。 看起来在我们的堆栈中持久连接的pipe理存在一些问题。 然而,我们的设置似乎是正确的,例如保持活动超时设置正确,Akamai 300秒,第一ELB302,Nginx304等等。 我也附上了Nginxdebugging日志的请求,任何一个感兴趣的。 这个失败的请求的情况是:DELETE / api / v2 / cart / ULBlIlptUun70M3h4cPm1t7Paos / line / 122555881 […]

使用nginx x-Accelcachingdynamic图像

我们试图caching请求到我们的nginx服务器上的图像。 即使图像是dynamic的,也会在短时间内频繁地请求相同的图像。 目前我们正试图用Nginxcachingx-accel请求来解决这个问题。 我们是否需要内部代理来启用这个function? 这甚至可能或者我们需要使用清漆? 如果可能的话,我们做错了什么? 我们的php代码: $image = $images[$randomNumber]; header("Content-Type: application/octet-stream"); header('X-Accel-Expires: '. 'max'); header('Content-Disposition: attachment; filename='.$image.''); header('X-Accel-Redirect: /protected_files/'. $image); 我们的网站启用configuration文件: proxy_cache_path /tmp/nginx levels=1:2 keys_zone=my_zone:1000m inactive=60m; proxy_cache_key "$request_uri"; server { listen 80 default_server; root /usr/share/nginx/html; index index.php index.html index.htm; charset utf-8; location / { proxy_cache my_zone; } location ~ \.php$ { try_files $uri =404; […]

Haproxy Nginx / Naxsi到Web服务器不工作

我有一个haproxy / nginx / naxsi设置负载平衡和安全性。 stream量应该进入haproxy然后到nginx / nasxi然后最终到达web服务器,如果他们通过了WAF。 我们也有一个不同的IP地址在前面,然后我们在后面做。 我做错了什么,它不会stream经nginx? 如果我绕过nginx / naxsi,它只会按照预期工作,所以在经过nginx时我只会得到503错误。 Inet – > Haproxy .5.3:80 – > .5.3:81 Nginx / Naxsi .6.3:81 – > .6.x:80 Web服务器 frontend ft_waf bind 10.0.5.15:80 name http mode http log global option httplog timeout client 25s maxconn 10000 # DDOS protection # Use General Purpose Couter (gpc) […]

Nginx的proxy_pass到Apache

我有一个用nginx作为反向代理的raspberrypi,另一台机器是nginx(用于owncloud)和apache(phpbb)。 redirect到nginx的作品,但不是redirect到Apache,而是redirect到owncloud。 我认为出于某种原因apache不“响应”的nginx代理,所以nginx代理使用第一个虚拟主机的字母顺序,而不是这个防火墙的问题,我用nmap检查端口也我可以直接访问Apache local_ip:8080,它的工作。 – nginx代理的虚拟主机: owncloud: http ://pastebin.com/G6Q6fiKz phpbb: http : //pastebin.com/Keb5t4gt – apache:phpbb vhost: <VirtualHost *:8080> #ServerName forum.spooky4672.me DocumentRoot /var/www/phpbb ErrorLog ${APACHE_LOG_DIR}/forum_error.log CustomLog ${APACHE_LOG_DIR}/forum_access.log combined </VirtualHost>

为什么我的连接到php-fpm.sock被拒绝?

我在这里看到了一堆关于这个问题的问题,但是没有一个答案帮助我。 我不断从nginx得到一个502错误,所以我看看access.log,看到当服务器试图连接到unix:/var/run/php5-fpm.sock时,我不断收到错误111 unix:/var/run/php5-fpm.sock 我已经重新启动php5-fpm,并确保套接字实际上在那里,但我一直得到这个错误。 你们知道为什么吗? 我的nginx.conf user www-data www-data; worker_processes auto; error_log /var/log/nginx_error.log; pid /run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; gzip on; gzip_disable "msie6"; access_log /var/logs/nginx/access.log; error_log /var/logs/nginx/access.log; server { listen 80 default_server; root […]

如何用play和angularjs代理设置nginx

我正在用nginx学习play framework和angularjs。 该游戏应用程序运行在9090端口上,而angularjs应用程序运行在9000上 。 我试图代理到/app/*所有请求到后端播放应用程序我曾尝试一些nginxconfiguration成功率较低。 下面是我尝试的/etc/nginx/sites-available/default文件。 server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; index index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { proxy_pass http://127.0.0.1:9000; } location /app { proxy_pass http://127.0.0.1:9090; } }

这是一个nginx的proxy_cache错误?

我有一个非常简单的代理configuration: http { proxy_cache_path /var/www/cache levels=1:2 keys_zone=s3-images-cache:50m inactive=1M max_size=1000m; proxy_temp_path /var/www/cache/tmp; server { listen 80; server_name images.example.com; location / { proxy_cache s3-images-cache; proxy_cache_key $scheme$proxy_host$uri$is_args$args; proxy_cache_bypass $http_purge_cache; proxy_cache_valid any 1y; proxy_pass http://images-example.s3.amazonaws.com; add_header X-Cache $upstream_cache_status; proxy_intercept_errors on; error_page 404 = @no_image; } location @no_image { return 403; } } } 现在在这里跟我来: 我们要求/image.jpg。 请求被发送到/image.jpg的代理(不存在)。 后端以404响应。 调用“proxy_intercept_errors on”和“error_page […]

Nginx反向代理 – 不存在的子目录和子域名redirect?

我有以下的nginxconfiguration: upstream toshiba15 { server toshiba15.local:80; } server { listen 443 ssl; server_name my.domain.com; ssl_certificate /etc/nginx/ssl/startssl-nginx.crt; ssl_certificate_key /etc/nginx/ssl/startssl-nginx.key; root /usr/share/nginx/html/; location /dev/ { proxy_pass http://toshiba15/; proxy_redirect http://toshiba15/ /dev/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 大多数情况下按预期工作,但是一个问题 – 当我在uri中指定一个不存在的子目录时,它会在代理(toshiba15)服务器的根目录中显示内容! 代理服务器有一个股票nginxconfiguration – 没有改变。 编辑 :我通过添加另一个服务器返回404,并使用正则expression式为我的server_names解决了子域问题 此外,如果我指定一个未定义的子域,它将redirect到代理服务器(my.domain.com)的根目录 谢谢!

使用nginx获取任何文本文件(包括robots.txt)上的404

我最近把我的CentOS 7机器从一个Apachenetworking服务器移到了一个nginxnetworking服务器上,而且在学习nginx的入口和出口时,我仍然在研究各种问题。 我偶然发现的一个问题是,在我的公共Web根目录中,文本文件(如robots.txt)无法访问。 我的服务器块configuration如下: server { listen 80; server_name example.com; root /var/www/example.com/public_html; index index.php; access_log /var/www/example.com/logs/example.com_access.log; error_log /var/www/example.com/logs/example.com_error.log error; location / { index index.php index.html; } location /reports { autoindex on; } location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } error_page 404 /var/www/html/404.html; error_page 500 502 503 504 […]

与PHP + NGINXconfiguration不一致的下载大小

我build立一个Joomla网站使用docman进行文件pipe理/下载。 该网站build立在运行Nginx 1.4.2和PHP5(FPM)的Ubuntu 14.04服务器上。 我遇到的问题是文件下载不一致(在大小方面)。 例如,我从网站下载了一个PDF文件6次,结果如下: 72KB 75KB 146KB 177KB(完整文件) 72KB 177KB(完整文件) 对于这个testing,完整的文件正确下载了6次。 其他4次文件不完整。 我的nginx.conf看起来像这样 user www-data; worker_processes 1; error_log logs/error.log; worker_rlimit_nofile 8192; events { worker_connections 4096; } http { include /etc/nginx/conf/mime.types; include /etc/nginx/proxy.conf; include /etc/nginx/fastcgi.conf; index index.php app.php index.html index.htm; default_type application/octet-stream; log_format main '$remote_addr – $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' […]