我们试图评估的设置非常简单 – 一台机器上的NginX(当前1vCPU,2GB RAM),两台独立机器上的两台后端Tomcat。 核心configuration如下: worker_processes 1; events { worker_connections 2048; use epoll; # multi_accept on; } http { # define load-balancing upstream upstream tomcatUpstream { ip_hash; server 192.168.xx.51:8080; server 192.168.xx.52:8080; } include /etc/nginx/mime.types; default_type application/octet-stream; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 0; # 45; # keepalive_requests 4096; reset_timedout_connection on; client_body_timeout 30; send_timeout 15; […]
我有一个运行在nginx后面的django应用程序。 所有这些都在负载平衡器后面运行。 负载均衡器正在使用HTTP健康检查来启用/禁用节点。 问题是,运行状况检查不会发送主机标题,Django无法执行请求。 我试图覆盖HOST在Nginx,但没有运气。 location /health-check { access_log off; uwsgi_pass application; proxy_read_timeout 10; proxy_pass_header Server; proxy_set_header Host health-check.xxxxx.com; proxy_set_header X-Forwarded-Host health-check.xxxxx.com; include /opt/conf/uwsgi_params; } 任何方式来pipe理它?
我使用纯粹的nginx作为反向代理。 我的/etc/nginx/看起来像这样: drwxr-xr-x. 2 root root 6 Jul 3 14:44 conf.d drwxr-xr-x. 2 root root 6 Jul 3 14:44 default.d -rw-r–r–. 1 root root 1.1K Jul 3 14:44 fastcgi.conf -rw-r–r–. 1 root root 1.1K Jul 3 14:44 fastcgi.conf.default -rw-r–r–. 1 root root 964 Jul 3 14:44 fastcgi_params -rw-r–r–. 1 root root 964 Jul 3 14:44 […]
我今天早上醒来,发现一个网站发生故障的通知。 我自己查了一下,结果没有。 我ssh进去检查服务器日志,而正常的请求正在处理罚款,uptimerobot的是这样的: 1.2.3.4 – – [23/Oct/2015:06:41:06 +0000] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0+(compatible; UptimeRobot/2.0; http://www.uptimerobot.com/)" 1.2.3.4 – – [23/Oct/2015:06:41:36 +0000] "GET / HTTP/1.1" 301 5 "-" "Mozilla/5.0+(compatible; UptimeRobot/2.0; http://www.uptimerobot.com/)" 1.2.3.4 – – [23/Oct/2015:06:42:06 +0000] "GET / HTTP/1.1" 499 0 "-" "Mozilla/5.0+(compatible; UptimeRobot/2.0; http://www.uptimerobot.com/)" 1.2.3.4 – – [23/Oct/2015:06:42:36 +0000] "GET / HTTP/1.1" 301 5 […]
我知道有很多问题如何用nginx中的其他东西(或者什么也不是)replaceURL的一部分,但是我确实吸收了正则expression式,并且绝对是nogin in nginx。 所以有人可以解释如何将URL如http://123.123.123.123:9090/v0/A8B9DEBF512F929144257AEE00262C16/$File/IMG_8819.jpg转换为http://123.123.123.123:9090/v0/A8B9DEBF512F929144257AEE00262C16/IMG_8819.jpg (没有$文件/,而不是A8B9DEBF512F929144257AEE00262C16和IMG_8819.jpg可能有数字和字母的任何组合)? 我尝试了这样的事情 location /v0 { rewrite ^(v0/[^/]+)/\$File/(.*)$ $1/$2 last; } 无济于事。 但显然这是正则expression式是错误的,因为至lessnginx认识到它应该做一些/ v0 /和我得到404。
我试图把我的网站从Apache移动到Nginx。 我的网站是这样构build的: www_root 上市 其他文件夹 所有请求都使用.htaccess从www_rootredirect到公用文件夹,其中包含: RewriteRule ^$ public/ [L] RewriteRule (.*) public/$1 [L] 在公共文件夹中 ,所有的请求都被redirect到单个入口点index.php .htaccess: RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?page=$1 [QSA,L] 目前我的服务器块是这样的: server { server_name domain.com www.domain.com; root /var/www/domain.com/htdocs/public; location / { # try to serve file directly, fallback to index.php try_files $uri /index.php$is_args$args; } location ~ ^/index\.php(/|$) { […]
我们制作了一个显示dynamic图像的应用程序。 我们试图用nginx处理一秒钟的2k图像请求。 图像的大小约为0.13 mb,我们使用这个代码的PHP服务的图像: header("Content-Type: application/octet-stream"); header('Content-Disposition: attachment;filename="'.$file.'"'); echo file_get_contents($file); 当我们用30秒(250秒)的7500请求加载服务器时,我们得到这个响应:响应的屏幕截图 这里的平均响应是5461毫秒。 我们得到了4GB的RAM digitalocean.com上的40GB SSD磁盘2核心vp我们可以做什么的build议?
我正在考虑编写一些逻辑到我的应用程序,以便它可以将静态页面内容写入s3或某个CDN,并主要从那里开始。 但是我不确定这是否可能。 例如,我有site.com/something,它应该首先在cdn中查找,如果不存在,则从varnishcaching或nginx / php-fpm提供服务。 这个想法是把stream量从服务器上拿走。 这是一个可能的情况? 在drupal中,我看到了一个模块来做到这一点 。 它将静态文件caching存储在磁盘中,并在其中存在。 下面是他们提供的图表。 他们问下面的.htaccess除外 # RewriteBase / ### BOOST START ### # Allow for alt paths to be set via htaccess rules; allows for cached variants (future mobile support) RewriteRule .* – [E=boostpath:normal] # Caching for anonymous users # Skip boost IF not get request OR uri […]
我的dist是Ubuntu 14.04 用例 我正在尝试创build一个名为“custom-nginx”的打包nginx。 它需要将自己安装到备用目录中,因此不会干扰nginx的正常运行。 'custom-nginx'将侦听不同的端口号并提供API请求。 一些命令我正在使用的准备 apt-get install dpkg-dev wget -O – http://nginx.org/keys/nginx_signing.key | sudo apt-key add – echo "deb http://nginx.org/packages/mainline/ubuntu/ trusty nginx" | sudo tee -a /etc/apt/sources.list echo "deb-src http://nginx.org/packages/mainline/ubuntu/ trusty nginx" | sudo tee -a /etc/apt/sources.list apt-get update apt-get source nginx apt-get build-dep nginx 我们现在有一个目录nginx-1.9.5 ,其中包含我们编译nginx所需的所有东西。 在nginx-1.9.5 / debian里面有一个control文件,打开那个,我可以看到在哪里更改第9行的包名 Package: nginx 至 […]
我目前正在使用Phusion Passenger + Nginx在服务器上运行一个简单的Meteor.js应用程序。 我想要做的就是对其进行configuration,以便在www.example.com上有一个主要应用程序,以及www.example.com等上的其他应用程序。 我怎样才能使用上述工具来实现这种configuration? 我知道如何做到这一点只使用nginx,但它似乎需要额外的乘客configuration。 我目前的nginxconfiguration如下: server { listen 80; server_name example.com; # Tell Nginx and Passenger where your app's 'public' directory is root /var/www/app1/bundle/public; passenger_friendly_error_pages on; # Turn on Passenger passenger_enabled on; # Tell Passenger that your app is a Meteor app passenger_app_type node; passenger_startup_file main.js; # Tell your app where MongoDB […]