Articles of nginx

我如何告诉Nginx跳过重写一些特定的位置?

这就是我所做的: 因为/api系统有HTTPS问题,所以我必须在HTTP下提供它。 其余的我强迫他们在HTTPS。 但是,在我的Django系统中,redirect让我回到http。 这可能与django有关,但现在我想把所有的HTTP重写为HTTP。 我通常会把它放在80服务器块,但我想保持/api作为HTTP。 我怎样才能使用重写? 谢谢。 server { listen 80; server_name localhost 127.0.0.1; server_name_in_redirect off; client_max_body_size 100M; location /api { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://localhost:5050; proxy_redirect default; } } server { listen 443; ssl on; location /app1 { …. proxy_pass http://localhost:1234; } location /app2 { … proxy_pass […]

在Nginx中复制Apache Multiviews + PATH_INFO

我正在使用之前使用Apache + Multiviews + PATH_INFO的一些旧的PHP代码。 我现在试图使用nginx(我使用和崇拜我所有的其他更新的工作)启动和运行此网站。 问题在于/ books / newreleases / 1420之类的URL,它实际上需要由/books.php来处理(以便php能够看到/books.php/newreleases/1420以及适当的PATH_INFO信息)。 我知道所有这些使用多视图的原因是一个坏主意,但重新开发这个网站来解决这个问题目前还不是一个select。 我可以通过使用rewrite( rewrite ^/books/(.*)$ /books.php/$1; )来使这个特定的例子工作rewrite ^/books/(.*)$ /books.php/$1;但是整个站点中有太多的文件来为每个东西进行重写的手动编码除了最后的手段。 另外,这让我难过。 我一直在阅读这里所有类似的问题,但无法find这个具体案例的答案,我也不知道是否有一个正确的方法来使用try_files来处理它。 这里是我的configuration肉: server { server_name foo.com www.foo.com; root /srv/www/foo.com/public_html; rewrite_log on; index index.html index.htm index.php; location / { rewrite ^/books/(.*)$ /books.php/$1; try_files $uri $uri.php $uri/ =404; } location ~ ^.+\.php { try_files $uri.php $uri/ […]

nginx + Jetty – 数以千计的连接卡在LAST_ACK中

我有一个带有jails的FreeBSD机器 – 特别是两个运行nginx的机器,另一个运行一个Java程序,通过Jetty接受请求(embedded模式) Jetty不断收到500个请求/秒,最近有一个问题,我将在Nginx和Jetty之间的LAST_ACK状态中持续有超过60,000个连接。 所有连接的分配(包括一些其他服务,特别是php-fpm) root@host:/root # netstat -an > conns.txt root@host:/root # cat conns.txt | awk '{print $6}' | sort | uniq -c | sort -n 18 LISTEN 112 CLOSING 485 ESTABLISHED 650 FIN_WAIT_2 1425 FIN_WAIT_1 3301 TIME_WAIT 64215 LAST_ACK 分发nginx – >docker连接 root@host:/root # cat conns.txt | grep '10.10.1.57' | awk '{print $6}' […]

nginx proxy_no_cache不起作用

我正试图build立一个2条件的caching反向代理; 如果满足,则不应该从原始存储文件: 部分内容请求 请求与查询string 如下configuration,我得到了nginx不存储部分内容的请求。 但是,它仍然使用查询string存储请求。 我在这里错过了什么? curl -r 1000-2000 http://edge.com/data/abcdef.dat [OK。 没有文件存储。] wget http://edge.com/data/abcdef.dat?query=string [不行。 abcdef.dat保存在边上。] 位置/数据/ { 设置$ originuri / origin $ uri $ is_args $ args; errorpage 404 = $ originuri; } 位置/原点/ { proxy_pass http://origin.com:1111; proxy_store / mnt1 / edge / store; proxy_temp_path / mnt1 / edge / tmp; proxy_set_header If-Range […]

Google对两个相同的nginx设置和200个代码的反应不同。 有任何想法吗?

我很困惑… 我有一个最近被克隆的linode.com VPS,所以nginx服务器的设置是一样的。 一个住在一个开发子域,一个在www上。 我正在尝试在我的实时服务器上运行Google实验,该实验声称: Web服务器拒绝utm_expid。 您的服务器不支持在URL中添加查询参数。 我的日志显示在开发服务器上它的工作原理: 74.125.186.32 – – [13/Sep/2012:13:33:45 -0700] "GET /product/iphone-case/?utm_expid=25706866-0 HTTP/1.1" 200 12521 "-" "Google_Analytics_Content_Experiments 74.125.186.32 – – [13/Sep/2012:13:33:45 -0700] "GET /product/iphone-case/?ab_reviews=True&utm_expid=25706866-0 HTTP/1.1" 200 14679 "-" "Google_Analytics_Content_Experiments 我的生产服务器显示谷歌提出第二个要求。 74.125.186.41 – – [13/Sep/2012:13:34:49 -0700] "GET /product/iphone-case/?ab_reviews=on&utm_expid=25706866-1 HTTP/1.1" 200 12104 "-" "Google_Analytics_Content_Experiments 74.125.186.41 – – [13/Sep/2012:13:34:49 -0700] "GET /product/iphone-case/?utm_expid=25706866-1 HTTP/1.1" 200 12122 […]

nginx:未知的“script_filename”variables

我尝试使用script_filename时收到此错误 nginx: [emerg] unknown "script_filename" variable nginx: configuration file /etc/nginx/nginx.conf test failed 但是script_filename在fastcgi_params定义 fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param GATEWAY_INTERFACE CGI/1.1; fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; […]

Nginx的子域WordPress重写规则 – APC FPC – 作为一只乌龟慢。 为什么?

运行在Ubunty 10.04 Nginx(最新之一)与WordPress的子域多站点使用插件。 APC我有最新版本与PHP相同,我运行4个网站几乎没有stream量(每天30点击每个)和云服务器rackspace(2gig ram,基本模型)似乎50%ram使用是正常的。 它的工作,但 1)我正在使用batcache,apc插件,但是我不确定给他们多less内存,目前是128megs。 我把APC放在128兆,因为日志中的错误要求更多的内存,下面看看它的外观。 http://i.imgur.com/dKTmz.jpg <— apc.php页面图的图像 2)JavaScript没有得到gzipped。 3)index.php是每一个单一的url,如果删除wordpress引发错误。 下面是我的cfg文件,请帮我看看丢失了什么,我查看了50个nginx页面的configuration文件,并对其进行了修改,因为它们都不适合我的设置 nginx.cfg user www-data; worker_processes 2; pid /var/run/nginx.pid; events { worker_connections 1024; use epoll; #v1 # multi_accept on; #v1 } http { ## # Basic Settings ## sendfile on; tcp_nopush on; #tcp_nodelay off; #v1 tcp_nodelay on; #v2 server_tokens off; include mime.types; default_type […]

Nginx + WordPress Multisite 3.4.2 +子目录+静态页面和永久链接

我正在尝试使用Nginx,php5-fpm,APC和Batcache来设置Wordpress多站点,使用子目录。 和许多其他人一样,我陷入了固定链接的重写规则中。 我已经按照这两个指南,这似乎是正式的,你可以得到: http : //evansolomon.me/notes/faster-wordpress-multisite-nginx-batcache/ http://codex.wordpress.org/Nginx# WordPress_Multisite_Subdirectory_rules 这是部分工作: http://blog.ssis.edu.vn的作品。 http://blog.ssis.edu.vn/umasse/作品。 但其他永久链接,如这两个到一个职位或静态页面,不起作用: http://blog.ssis.edu.vn/umasse/2008/12/12/hello-world-2/ http://blog.ssis.edu.vn/umasse/sample-page/ 他们要么带你到404错误,要么到其他的博客! 这是我的configuration: server { listen 80 default_server; server_name blog.ssis.edu.vn; root /var/www; access_log /var/log/nginx/blog-access.log; error_log /var/log/nginx/blog-error.log; location / { index index.php; try_files $uri $uri/ /index.php?$args; } # Add trailing slash to */wp-admin requests. rewrite /wp-admin$ $scheme://$host$uri/ permanent; # Add trailing slash to […]

nginx 2 symfony2 web应用程序,一个ip没有域名

我对nginx感到恼火。 我在/ usr / share / nginx / www / firstapp中设置了一个应用程序,在/ usr / share / nginx / www / secondapp中。 在我的默认configuration我安装在/根本地化我想第一个应用程序:当在浏览器中写9.9.9.9显示我的第一个应用程序,当我写9.9.9.9/makeup,没有显示我第二个应用程序。 为什么第一个应用程序显示我很好,seccondapp不能? 请帮帮我。 对不起,质量这里pasterbin代码: 在这里input链接描述 server { listen 80; server_name localhost; root /usr/share/nginx/www/firstapp/web; access_log /var/log/nginx/$host.access.log; error_log /var/log/nginx/error.log error; # strip app.php/ prefix if it is present rewrite ^/app\.php/?(.*)$ /$1 permanent; location / { root /usr/share/nginx/www/firstapp/web/; […]

应用程序报告超时。 然而nginx没有logging或日志

我们通过nginx / uwsgi服务于Django。 我们在VPC后面使用AWS ELB。 这是移动客户端的web服务。 我们在开发过程中报告了超时,所以我们为每个请求添加了一个request_id的概念 客户端生成请求标识 发送GET / request?_request_id = ABDFEFE 如果发生错误,则将错误与请求ID一起报告给服务器 我现在遇到的问题是我得到了在野外发生的超时错误报告。 但是,相关的request_id不会显示在任何nginx或uwsgi日志中。 我有点怀疑亚马逊弹性负载平衡器。 但是我不能确定。 由于这是一个超时我们没有ELB标题看,或状态码或响应身体或任何东西。 我们使用newrelic来监视我们的后端。 偶尔会logging3-4秒的“慢速交易”。 (没有像大多数客户端库中典型的30秒超时) 实际的问题:下一步看什么? 根据我和我在服务器上的数据,NOTHING实际上是错误的,但超时仍然存在。 在这一点上,我甚至不知道如何开始debugging。 应用程序服务器运行在10%的容量(对于mem和cpu)缓慢的sql查询正在被logging(没有什么有趣的) (我也在分别查看客户端错误) 提前致谢。