Articles of nginx

在一个子URI下服务Tomcat

我有很多附加到单个域的服务,所以我希望在http:// server_name / tomcat之下提供Tomcat,Nginx作为Tomcat HTTP连接器的反向代理。 Nginx的configuration非常简单: location /tomcat { include proxy_pass.conf; proxy_pass http://127.0.0.1:8080; } 如果我保持原样,Tomcat无法parsing以/tomcat开头的请求,但是如果我另外设置了alias /; 在Nginx中,那么Tomcat工作的很好,但不幸的是,它不能解决它所服务的path,所以所有的URL都丢失/tomcat 。 我经历了几次Tomcat 7的configuration参考 ,但是我找不到任何能够让我configurationTomcat为/tomcatpath下的所有应用程序提供服务的地方,或者将它作为前缀添加到上下文中每个应用程序的path。 我可以为每个应用程序手动configuration一个<context/>容器的server.xml ,但这只会让我感到不安。 谁能告诉我,我明显失踪的是什么?

如何在Nginx中将每个https请求redirect到http?

这个问题已经被StackOverflow问过很多次,但是我的问题有点不同: 我有多个子域网站: http://www.example.com http://my.example.com https://admin.example.com http://client.example.com 正如你所看到的,只有pipe理员通过https服务。 我成功地在Nginx中创build了所有的虚拟主机,并且运行良好。 但现在,我想通过https将所有尝试访问其他子网站的客户端redirect到http: https://www.example.com =>redirect到http://www.example.com https://my.example.com =>redirect到http://my.example.com https://client.example.com =>redirect到http://client.example.com =>只有pipe理员相反。 我的第一个想法是设置每个https域的redirect: server { listen 443; server_name www.example.com; rewrite ^(.*) http://www.example.com$1; } 并为每个子域(www,我的和客户端)做了这个。 但是这不起作用,我的浏览器出现SSL错误(SSLlogging太长)。 我怎样才能做到这一点? 谢谢你的帮助!

NGINX基本authentication超时?

我已经保护与满意和basic_auth一个目录,但似乎validation没有存储在一段时间后,它被删除,似乎是ip或基于的东西。 所以我login一次,如果我保持半小时的网站开放,它不会重新请求validation。 有没有办法设置超时? 即访问10分钟,之后,如果点击文件又必须重新login?

在同一台服务器上使用Nginx和Apache的潜在问题?

我安装了nginx来处理和apache一起的请求。 之前,apache在80端口上收听,现在我已经切换到nginx监听端口80和apache在一些模糊的端口,并有nginx proxy_pass到Apache,如果请求是非静态内容。 我的nginxconfiguration包含以下内容: server { listen 80; server_name static.test.domain.com; location / { root /home/test/www/static; index index.html index.htm; } } server { listen 80; server_name domain.com *.domain.com; location / { proxy_set_header Server "testserver"; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://localhost:8800; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } […]

有人试图破解我的网站? 如何阻止Nginx中的某些URL?

在过去的几个小时里,我的服务器变得非常漂亮,主要是由于大量的加载请求。 我已经看到了这一点,这要归功于StatCounter的实时统计,它显示“来自”页面是: http://www.facebook.com/extern/login_status.php?api_key=3d34061e0ac6dc4dec21b35d2fb9d6d3&extern=0&channel=http%3A%2F%2Fwww.mysite.com%2F%3Fxd_receiver%3D1&locale=es_ES&sdk=edgar 着陆页是 http://www.mysite.com/?xd_receiver=1#%7B%22id%22%3A0%2C%22sc%22%3A%22http%3A%2F%2Fwww.facebook.com%2Fxd_receiver_v0.4.php%22%2C%22sf%22%3A%22loginStatus%22%2C%22sr%22%3A2%2C%22h%22%3A%22loginServer%22%2C%22sid%22%3A%220.162%22%2C%22t%22%3A0%7D%5B0%2C%22loginStatus%22%2C%22InitLogin%22%2C%7B%22b CPU,内存和带宽越来越高,我想现在如果这可能是某种攻击。 这是一个WP 3.2.1的WordPress博客,基于Ubuntu 10.04.2 LTS,带有Nginx,PHP-FPM和APC。 通常它运行得很好,但我很担心这个请求是加载服务器很多。 我唯一的解释是,我有一个简单的Facebook连接插件允许评论与Facebook帐户,但它没有给任何问题,直到现在。 奇怪的是,access.log显示请求来自不同的IP地址,所以我猜这不是攻击 164.77.106.237 – – [19/Oct/2011:18:20:53 +0200] "GET /?xd_receiver=1 HTTP/1.1" 403 189 "http://www.facebook.com/extern/login_status.php?api_key=3d34061e0ac6dc4dec21b35d2fb9d6d3&extern=0&channel=http%3A%2F%2Fwww.mysite.com%2F%3Fxd_receiver%3D1&locale=es_ES&sdk=edgar" "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; InfoPath.1)" 212.104.164.139 – – [19/Oct/2011:18:20:48 +0200] "GET /?xd_receiver=1 HTTP/1.1" 403 135 "http://www.facebook.com/extern/login_status.php?api_key=3d34061e0ac6dc4dec21b35d2fb9d6d3&extern=0&channel=http%3A%2F%2Fwww.mysite.com%2F%3Fxd_receiver%3D1&locale=es_ES&sdk=edgar" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1" etc. […]

Nginx:只caching主页

如何指定位置指令来caching我的主页,而不需要任何文件名或扩展名后缀。 我只需要在site.comcaching我的主页,而不是在它下面的任何东西(即site.com/page.php)。

Nginx PHP-FPM基本authentication

我有nginx在Debian Squeeze上安装了php-fpm 。 目录树是: 在/ var / WWW / mysite的 的index.php secret_folder_1 admin.php的 static.html secret_folder_2 admin.php的 static.html 图片 img01.jpg 我需要用basic_authclosuressecret_folder_1和secret_folder_2 。 现在configuration看起来像: location ~ /secret_folder_1/.+\.php$ { root /var/www/mysite/; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /var/www/mysite$fastcgi_script_name; include fastcgi_params; auth_basic "Restricted Access"; auth_basic_user_file /path/to/.passwd; } location ~ /secret_folder_1/.* { root /var/www/mysite/; auth_basic "Restricted Access"; auth_basic_user_file /path/to/.passwd; } 相同的configuration为secret_folder_2 。 […]

nginx作为一个代理和“即发即弃”的请求

我们使用nginx作为处理callback请求的Rails应用程序的代理。 这些请求中的一部分以“即忘即忘”的方式发送给我们。 意思是,客户端在发送请求之后立即closures连接,而不用等待响应。 Nginx取消请求,logging一个499,没有任何东西通过Rails应用程序。 是否可以configurationnginx,这样它仍然将请求转发给Rails应用程序,即使客户端closures连接后,它已被发送?

nginx:error_page不起作用

我尝试使用此snipplet为我的Rails应用程序设置维护页面。 error_page 503 /system/maintenance.html; if (-f $document_root/system/maintenance.html) { return 503; } 只要存在maintenance.html,就会使webserver返回503.但是它返回的是最小的nginx默认的error_page,而不是我的maintenance.html。 为什么? Ubuntu 10.04 LTS上的nginx 1.0.12 完整的虚拟主机configuration: https : //gist.github.com/1948225

如何让nginx只响应一个域?

我对nginx很新,我把我的rails应用程序托pipe在nginx + passenger上。 我希望我的网站只能访问一个域名。 所以我设置我的nginx conf如下: server { listen 80; server_name mydomain.com www.mydomain.com; root /var/deploy/myapp/current/public; passenger_enabled on; location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires 1y; add_header Cache-Control public; } } 我指定了server_name指令,但它仍然回答任何指向此IP的内容,我可以在access.log中看到它对其他域名的回应。 有什么我做错了吗?