我使用Nginx和Passenger作为我的Rails应用程序。 我想使用代理caching来caching我的网页。 但是,每个请求都直接导入到我的rails应用程序中。 我不知道我的configuration有什么问题。 以下是我的configuration: user www-data; worker_processes 1; events { worker_connections 1024; } http { passenger_root /usr/lib/ruby/gems/1.8/gems/passenger-2.2.15; passenger_ruby /usr/bin/ruby1.8; passenger_max_pool_size 6; passenger_max_instances_per_app 1; passenger_pool_idle_time 0; rails_spawn_method conservative; include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 512; sendfile on; #tcp_nopush on; keepalive_timeout 65; tcp_nodelay on; gzip on; gzip_http_version 1.0; gzip_vary on; gzip_comp_level 6; gzip_proxied any; gzip_types text/plain text/css […]
我将负责在不同的盒子上对两个node.js / Socket.io实例进行负载平衡,nginx运行一个简单的通知服务,并为新客户端提供追溯事件。 我不认为websocket连接types(这将是连接的主要方法)会有任何问题,因为维护的连接会否定会话的需要(除了重新连接,我不会太担心) 。 然而,轮询后备方法会有问题,因为它们依赖于客户端会话,并且在标准的roundrobin负载平衡(在这种情况下)下一轮民意调查将成为新客户的可能性为50%。 不是在两个盒子之间同步会话,而是让负载均衡器使用ip_hash指令或nginx-sticky-module来做一些半智能的路由。 ip_hash好像可以做这个工作,但是我可以看到它在移动客户端有潜在的问题,他们在3G上交换IP地址,或者在移动networking和WiFi之间改变IP地址,从而改变IP地址。 我有几个与此相关的问题。 如果你可以回答那个很棒的话 ip_hash是否有任何forms的寿命,或者IP地址是否永久分配给后端实例? 任何人都可以分享与Socket.io和/或移动客户端使用nginx负载平衡的经验/build议吗?
有人为Nginx创build了一个类似的http://apache.webthing.com/mod_proxy_html/ mod_proxy_html模块? 我认为最接近的模块是http://wiki.nginx.org/HttpSubsModule,但我不知道如何configuration这个来重buildapache模块的function。 谢谢!
我有一个简单的nginxconfiguration; server{ servername localhost; root /var/www/webroot; location / { set_md5 $memcached_key $uri; index index.php index.html; try_files $uri $uri/ @cache; } location @cache { memcached_pass localhost:11211; default_type text/html; error_page 404 @fallback; } location @fallback{ try_files $uri $uri/ /index.php?url=$uri&$args; } location ~ \.php$ { fastcgi_param MEM_KEY $memcached_key; include /etc/nginx/fastcgi.conf; fastcgi_index index.php; fastcgi_intercept_errors on; fastcgi_pass unix:/var/run/php5-fpm.sock; } } […]
我已经做了几天的阅读这个问题,诚然,我是一个Nginx新手。 我已经阅读了官方和非官方的文件,似乎无法解决我的问题。 希望这里有人能够帮我一把。 我可以服务我的HTML页面,如403,404和50x.html,所以我知道nginx正在一定的能力。 我的httpsredirect也适用。 我可以telnet到9001上的PHP FPM。 我的所有权限都是正确的,至less对我来说是正确的 我在下面包含了相关的configuration文件和输出: 网站可用/默认: server { listen [::]:80; server_name domain.com; return 301 https://domain.com$request_uri; #rewrite ^ https://domain.com$request_uri? permanent; } server { listen 443 default ssl; server_name domain.com; ssl on; ssl_certificate /etc/ss-certificates/ss-domain.com.crt; ssl_certificate_key /etc/ss-certificates/ss-domain.com.key; root /var/www/domain.com/wwwroot; index index.php; access_log /var/www/domain.com/logs/access.log combined; error_log /var/www/domain.com/logs/error.log debug; error_page 404 /404.html; error_page 403 /403.html; error_page […]
我试图设置一个运行Django的Gunicorn WSGI服务器。 设置似乎运行,除了我有一个权限问题。 我已经设置了别名到/ media和一个/静态目录来提供静态内容,但是除非文件被nginx用户所有,否则会产生一个403错误。 由Gunicorn用户上传的文件显然将由该特定用户拥有,这将导致问题。 我可以将nginx用户添加到gunicorn用户组,但是我不想给这些文件赋予nginx一揽子权限。 什么是通过Gunicorn / Wsgi / Django上传或生成文件的build议方法,但允许nginx服务他们没有增加安全问题。 提前致谢,
我有一个使用nginx,uWSGI和Django构build的API的web应用程序。 最近我在一个特定的API调用中看到了很多harakiris,它会进行一些快速处理,然后产生一些线程来处理一些长时间运行的函数。 主线程然后返回并且工作线程将其结果存储在caching中并退出。 在线程产生之后,它们之间没有交互。 我的uWSGI在20秒内被设置为harakiri。 这应该是足够的时间让主线程完成并返回(平均大约2-3秒)。 uWSGI是否有可能因为我的工作线程太长而返回? 如果是这样,我可以解决这个问题,而不是multithreading在python中的多处理? 谢谢!
我通过与nginx连接的fcgiwrap提供可执行脚本(主要是C语言)。 由于脚本已经编译,所以在编译过程中我可以得到编码错误,但是有时候我会收到CGI错误 An error occurred while reading CGI reply (no response received) 有没有任何debugging方法来确定CGI请求/处理有什么问题? 我怎样才能设置一个debugging系统将错误提交到nginx日志?
我在使用Cloudflare加速服务的时候,在我的nginx.conf http块中使用了下面的configuration来获取真实的IP地址: ## Cloudflare settings to get Real IP's set_real_ip_from 204.93.240.0/24; set_real_ip_from 204.93.177.0/24; set_real_ip_from 199.27.128.0/21; set_real_ip_from 173.245.48.0/20; set_real_ip_from 103.21.244.0/22; set_real_ip_from 103.22.200.0/22; set_real_ip_from 103.31.4.0/22; set_real_ip_from 141.101.64.0/18; set_real_ip_from 108.162.192.0/18; set_real_ip_from 190.93.240.0/20; set_real_ip_from 188.114.96.0/20; set_real_ip_from 197.234.240.0/22; set_real_ip_from 198.41.128.0/17; set_real_ip_from 162.158.0.0/15; set_real_ip_from 2400:cb00::/32; set_real_ip_from 2606:4700::/32; set_real_ip_from 2803:f800::/32; set_real_ip_from 2405:b500::/32; set_real_ip_from 2405:8100::/32; real_ip_header CF-Connecting-IP; 我也使用在上面的configuration下定义的nginx速率限制function,如下所示: limit_conn_zone $binary_remote_addr zone=two:30m; 这是由limit_conn two […]
我的一个客户正试图通过使用XHR2表单数据(以及CORS的跨域请求)的表单POST将file upload到我们的远程nginx web服务器。 在上传期间,networking服务器返回一个408,结果ajaxerror handling程序停止处理。 这些文件在20-120MB的范围内。 一些file upload的访问日志如下(他已经在Chrome 31和IE11上试过): [24/Dec/2013:16:44:18 -0500] "OPTIONS / HTTP/1.1" 200 0 "http://www.example.com/files/upload" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36" [24/Dec/2013:16:47:50 -0500] "POST / HTTP/1.1" 408 0 "http://www.example.com/files/upload" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36" … [27/Dec/2013:01:23:51 -0500] "OPTIONS / HTTP/1.1" 200 0 […]