Articles of nginx

使用uWSGI作为代理服务器

题: 有没有办法使用uWSGI作为代理服务器? 更多关于系统: 6个负载均衡的nginix / uWSGI服务器 python 要求: 设置几个代理服务器,可以: 接受来自客户端浏览器的请求 阅读并修改请求URL 阅读和修改请求标题 转发请求到另一个代理服务器 我们想使用uWSGI作为代理服务器的原因是因为我们已经在应用程序中使用了uWSGI,并且所有的Python代码都可以使用它。 现在,我们使用uWSGI在后端为Python提供一个RESTful的http API。 据我所知,代理服务器的工作方式不同于REST API。 请原谅我的无知,我对代理服务器知之甚less,以及它们是如何工作的。 我也意识到这些要求听起来很古怪,但我向你保证,有一个原因和韵律。 非常感谢!

为什么nginx为目录别名中的请求提供错误的MIMEtypes?

如果有一种方法可以不使用别名来完成这个典型的任务,我完全可以。 我希望/minesweeper/* URL中的所有请求都被从完全不同的目录中提取,而不是其他请求。 下面的configuration工作,文件被提供,但MIMEtypes是应用程序/八位字节stream,而不是它应该是(即文本/ CSS)。 使用不正确的MIMEtypes,Web浏览器不可能在文档中呈现CSS样式。 nginx.conf: http { index index.html include /etc/nginx/mime.types; default_type application/octet-stream; … } virtual.conf: server { listen *:80; server_name djmp.org www.djmp.org; root /home/devsites/djmp.org/public_html/; index index.html; location ~ ^/minesweeper($|/.*) { alias /home/michael/sites/minesweeper$1; } }

如何正确configurationPlay Framework 2.1+和Nginx的生产?

我正在尝试使用Nginx作为Amazon AMI上的前端HTTP服务器来正确设置Play Framework。 我对Play发布的官方文档有点困惑。 他们build议你跑步吗? start -Dhttp.port=9000 然后configurationNginx重新路由到端口9000为了正确地提供我的应用程序? 我觉得有一个专门的用户只是为了运行启动命令是一种浪费,是不是有更好的方法来做到这一点? 我真的很感激一些生产Play Frameworknetworking应用程序的最佳实践的基本策略。

将nginx网站连接限制在同一台服务器上的VPN用户

我的主要目标是:在服务器上安装一个VPN服务器,并且该服务器上的一个网站应该只能被在同一台服务器上使用VPN的用户访问。 首先,这两个服务器的情况下工作。 也就是说,我有两个服务器,A和B.PPTP VPN服务器安装在A中,nginx在B上。 我已经为我的nginx站点设置了允许规则,如下所示,它们工作正常: allow ip_of_a; deny all; 但是,当我尝试连接A上的一个站点(VPN服务器也有一个Nginx服务器)时,我的远程IP显示为我的原始IP,而不是通过VPN连接时获得的IP,并且在nginx上获得403 Forbidden页面。 错误日志显示来自我原始IP的连接尝试,而不是VPN的IP。 我知道VPN仍然知道我的原始IP,而不是它提供给我的IP,但是应该有一种解决方法。 VPN分配的本地IP的forms允许10.80.80。*,所以我把另一个允许的forms allow 10.80.80.0/24; 这没有办法。 我也尝试直接添加VPN给我的本地IP,但它再次没有工作: allow 10.80.80.100; 这是否需要以某种方式从pptp服务器修复,还是可以从nginx规则修复? 编辑:连接到vpn之前和之后客户端(OS X)上的路由表: 之前: Internet: Destination Gateway Flags Refs Use Netif Expire default 192.168.1.1 UGSc 18 0 en0 127 127.0.0.1 UCS 0 0 lo0 127.0.0.1 127.0.0.1 UH 17 12724964 lo0 169.254 link#4 UCS 0 0 […]

在Nginx中使用gzip static on / sendfile时强制分块传输?

当发送预压缩ala gzip_static on文件时,Nginx似乎禁用了分块gzip_static on 有没有办法强制它大块呢? 块看起来给一些浏览器渲染速度更快的错觉,因为它们可能会使用块点作为渲染刷新点。 HTTP / 1.1应允许任何文件分块发送,静态或不。 或者,这可能是sendfile的OS加速的限制吗?

nginx代理websockets,一定是缺less的东西

我有一个基本的聊天应用程序,使用express和socket.io在node.js中编写; 直接连接到端口3000上的节点时,它工作正常 但是,当我尝试使用nginx v1.4.2作为代理时,这并不起作用。 我开始使用连接图 map $http_upgrade $connection_upgrade { default upgrade; '' close; } 然后添加位置 location /socket.io/ { proxy_pass http://node; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Request-Id $txid; proxy_set_header X-Session-Id $uid_set+$uid_got; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_buffering off; proxy_read_timeout 86400; keepalive_timeout 90; proxy_cache off; access_log /var/log/nginx/webservice.access.log; error_log /var/log/nginx/webservice.error.log; } […]

Nginx的fastcgi分裂与邮递员的path信息

我用nginx使用mailman来获得它的web界面,这是我的nginxconfiguration: location /cgi-bin/mailman { root /usr/lib/; fastcgi_split_path_info (/cgi-bin/mailman[^/]*)/(.*)$; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $fastcgi_path_info; fastcgi_intercept_errors on; fastcgi_pass unix:/var/run/fcgiwrap.socket; } 当我打电话到mydomain.com/cgi-bin/mailman/listinfo ,似乎工作得很好,但是当我要求类似于: mydomain.com/cgi-bin/mailman/listinfo/mylist我得到403和在nginx错误日志: FastCGI sent in stderr: "Cannot chdir to script directory (/usr/lib/cgi-bin/mailman/listinfo)" while reading response header from upstream 我尝试了每一个正则expression式来获得它的工作,但它仍然给予任何帮助或任何线索得到它的工作。

在nginx服务器之间共享authentication数据

我有一个使用端口9200和9292(用于logstash)的http服务器。 由于服务器不支持身份validation,我想设置一个nginx反向代理来处理身份validation。 这是我使用的configuration: server { listen 9292 default_server; server_name proxy_host; location / { proxy_pass http://logstash_server:9292; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; auth_basic "Restricted"; auth_basic_user_file /etc/nginx/.htpasswd; } } server { listen 9200 default_server; server_name proxy_host; location / { proxy_pass http://logstash_server:9200; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; auth_basic "Restricted"; auth_basic_user_file /etc/nginx/.htpasswd; […]

Nginx反向代理导致redirect循环

我有一个负载均衡器(Nginx)和另一个托pipewordpress博客的Apache服务器(在/博客)。 我希望在我的负载均衡器/blog上的所有stream量都能够访问此Apache服务器。 我有以下设置: upstream main_app { server main_app_address; } upstream blog { server blog_address; } server { server_name appname.com; return 301 http://www.appname.com$request_uri permanent; } server { listen 80; server_name appname.com; location / { client_max_body_size 8M; proxy_pass http://main_app; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Scheme $scheme; } location /blog { proxy_pass http://blog/; proxy_set_header Host $host; […]

php5-fpm最大化所有内核(nginx + php5fpm + wordpress)

我们有一个运行8个cpu内核的16个gode linode,我试图debugging一个问题,当我尝试一个负载testing时,服务器开始在一个非常基本的WordPress站点上发出大约250个请求。 我只打在网站的头版fyi。 当我login到服务器并查看Htop上的服务器统计数据时,我发现所有核心都被挂钩,并且php5-fpm进程的垃圾负载也是如此。 testing完成后,这些过程仍然存在,我最终必须重新启动php-fpm才能使服务器恢复正常运行。 我今天在做日志的时候看到了这个。 [23-Dec-2013 12:19:03] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 8 children, there are 0 idle, and 27 total children [23-Dec-2013 12:19:04] WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and […]