我们在nginx.conf中已经有了这个设置了很长时间了。 sendfile on; 当我们更新了一个文件如/js/main.js并从浏览器https://test.com/js/main.js?newrandomtimestamp进行访问时,它仍然会加载旧版本,除非我们进行完全刷新(清除caching)从我们的浏览器。 但是当我们从sendfile改变设置的时候; 发送文件closures; 浏览器将加载更新文件的正确版本。 对于我们的生产Web服务器,我们应该使用sendfile; 或closures发送文件;? 如果发送文件; 是需要的(可能是为了更好的caching?更快的性能?)那么如何解决上述问题? 下面是我们的生产服务器中的nginx.conf,我们使用的是1.7.5版本: user nginx; worker_processes 2; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr – $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; client_max_body_size 8m; […]
Ubuntu 14.04 apt-get install nginx apache2-utils 然后vi /etc/nginx/sites-enabled/default这些内容: server { listen 80 default_server; location / { return 200 "Ok"; } } service nginx restart 运行: ab -c 500 -k -n 100000 127.0.0.1/ 我得到的结果是: Percentage of the requests served within a certain time (ms) 50% 0 66% 0 75% 0 80% 0 90% 0 95% 0 […]
我目前有一个这样configuration的Nginx。 location /ui/ { proxy_pass http://ui:8888/; } 这个工程,但我有问题从服务中检索一些资源,例如,一些css样式引用/styles/style.css给404。我怎样才能告诉浏览器,基地址是/ ui /并不是 / ? 可能吗? 我也testing过这个configuration没有运气: location /ui/ { proxy_pass http://ui:8888/; proxy_redirect http://$host/ /ui/; proxy_set_header Host $host; }
为什么Nginx的proxy_pass向上游发送有时候传出的请求到IPv6? 2015/12/28 14:11:06 [error] 38194#0: *114469948 connect() failed (111: Connection refused) while connecting to upstream, client: xx.xxx.xx.xxx, server: example.com, request: "POST /suggest/ HTTP/1.1", upstream: "http://[AAAA:BBB:CCC:DDDD::E]:5555/suggestion", host: "example.com", referrer: "https://example.com/en/apple-111111/" nginx.conf: location /suggest/ { proxy_pass http://testserver.com:5555/suggestion; proxy_set_header Authorization 'Basic xxx'; } 而不是发送请求到我们的testserver.com请求去http:// [AAAA:BBB:CCC:DDDD :: E]:5555 /build议 有人知道IPv6地址来自哪里,或者nginx conf有什么问题? 感谢您的build议,汉斯 这是一个真实的例子: 2015/12/28 14:11:03 [error] 38192#0: *114552633 connect() […]
我正在运行Nginx的v1.8.0来服务我所有的静态文件和node.js来做dynamic的东西。 Nginx需要做的一件事就是将代理文件转移到存储文件的node.js中。 node.js似乎得到〜26K的文件,然后什么都没有(甚至不知道当数据“完成”发送时连接closures)。 我的configuration是这样的: location /attachment_upload/ { client_body_temp_path /tmp/; client_body_in_file_only clean; client_body_buffer_size 256k; client_max_body_size 1g; proxy_set_header X-FILE $request_body_file; proxy_http_version 1.1; proxy_buffering off; proxy_pass http://10.10.1.20:8090/attachment_upload/; expires epoch; } 我已经安装了curl,看看能否获得更多信息。 它立即返回(所以它看起来不像是我的超时),没有错误。 我检查了Nginx错误日志,没有看到任何内容。 如果我拿Nginx的图片node.js完全是我所期望的。 我已经呆了好几天了。 我已经尝试了我遇到的一切。 不知道接下来要检查什么…
Update2:添加uwsgi_ignore_headers Cache-Control Set-Cookie X-Accel-Expires Expires Vary; 并解决问题。 感谢大家。 更新:我试过uwsgi_ignore_headers Cache-Control Set-Cookie X-Accel-Expires Expires Vary; 。 不工作。 我还发现,如果我在同一台计算机上的不同浏览器中以相同的请求login状态,caching仍然不起作用。 这真的很傻… 我已经看到下面的评论,但我不知道如何将其应用到configuration文件。 我想cachingurl / ,它运作良好,但我发现,如果我login或注销,caching不工作。 为什么? 我只是想caching/反正。 这是我的configuration: uwsgi_cache_path uwsgi_cache_path /app/path/nginx_cache levels=1:2 keys_zone=my_cache:1m max_size=50m inactive=30m use_temp_path=off; server { … location = / { uwsgi_pass 127.0.0.1:3032; include /app/path/uwsgi_params; uwsgi_cache my_cache; uwsgi_cache_key "$host$uri$is_args$args"; uwsgi_cache_valid 5m; } … }
我有一个工作 nginxconfiguration代理从一系列源IP到服务器的所有请求。 我目前有20个源IP设置,configuration相当庞大。 为了简洁起见,我删除了其他18个街区。 我想知道是否有一个更简单的方法来做到这一点。 我需要添加100个以上的IP,configuration太大了。 一定会有更好的办法! 澄清:我需要从服务器上提供的100个随机IP地址之一发出的请求。 目标服务器将看到来自100个地址之一的代理请求。 HAProxy或其他替代scheme会更适合这种任务吗? 简化的nginxconfiguration: # nginx proxies all requests to one of these servers upstream cluster { # one server line for every server block configured below server 127.0.0.1:8000; server 127.0.0.1:8001; # 18 more… least_conn; keepalive 16; } # one server block for every source ip address configured […]
每次当我尝试发布我的网站,我得到几分钟后502错误的网关错误,并在我的default-error.log文件我得到这个错误反复(文件大小为360MB ..): 2016/02/03 14:57:28 [error] 1044#1044: *7248 connect() to unix:/var/run/php/php7.0-fpm.sock failed (11: Resource temporarily unavailable) while connecting to upstream, client: 123.456.78.90, server: default, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "domain.com" 服务器configuration 操作系统:Ubuntu 14.04.3 LTS(GNU / Linux 3.13.0-71-generic x86_64) Nginx版本:1.9.10 PHP版本PHP 7.0.2-4 + deb.sury.org〜trusty + 1(cli)(NTS) (我的服务器托pipe在数字海洋,它有4GB的RAM)。 nginx.conf : server { listen 80 default_server; server_name […]
我们正在使用Nginx,并希望减less我们拥有的“链接”redirect的数量。 所以,例如:URL A – http://www.sitename.co.uk/SHOPPING-CATEGORIES/product_name redirect到它的https版本(这是redirect1,将http更改为https) redirect的url然后redirect到相同的url,但都是小写的。 所以/ SHOPPING-CATEGORIES /成为/购物类别/(这是redirect2,将所有url更改为小写,因为它们区分大小写) redirect的url然后redirect到URL B – https://www.sitename.co.uk/category/product_name (这是redirect3删除string/购物类别,因为这不再使用任何url) 以上创build了三个单独的redirect,其中实际需要/需要的是 urlAredirect到urlB 这怎么能最好的实现呢? 非常感谢任何input
我试图优化一个数字海洋液滴(512mb),使用loader.io进行testing 我正在testing我的主页,这是HTTPS / PHP。 我设置了FastCGI页面caching,从100 req / sec到2000 req / sec。 但是超过2000 req / sec的任何事情都会导致很多超时和缓慢的响应(平均从20ms到1500ms)。 我试图找出瓶颈。 这不是CPU /内存,因为负载刚刚达到0.30,内存使用量大约是一半。 我尝试调整到更大的水滴,超时仍然发生。 这不是FastCGI,因为基本的.html文件的负载testing性能几乎相同。 在超时期间,error.log是空的。 没有什么似乎是抛出错误(我可以find)。 Kern.log有这个日志: TCP: Possible SYN flooding on port 80. Sending cookies. Check SNMP counters TCP: Possible SYN flooding on port 443. Sending cookies. Check SNMP counters. 我试图禁用syncookies,它停止了这些错误,但超时仍然存在。 在超时期间,我开始看到TIME_WAIT的积累: netstat -ntla | awk '{print $6}' […]