Articles of nginx

浏览器(铬,火狐)下载静态文件与Nginx缓慢,而不是与Apache2

我努力的事实是,当Nginx的服务1.8 GB的文件,当我把url在Chrome或Firefox的下载与5 Mb / s的,当我用wget或curl,相同的url,相同的客户端PC,下载与(我的最大)25 Mb / s。 使用Apache服务相同的文件,浏览器和curl / wget都会达到25Mb / s。 我的问题是:为什么? 这是一个很漂亮的默认configuration,我把X-Sendfile(apache2)或X-Accel-Redirect(Nginx)放在头文件中,我用nginx试过了几个configuration文件,我可以用limit_rate减慢configuration,但是不能启动。 这是/ etc / nginx / sites-enabled中默认链接的位置部分: location files/ { internal; alias /var/www/html/; #directio 100m; output_buffers 2 512k; limit_rate 30000k; sendfile_max_chunk 0; } 我打开directio,在其他选项左侧或左侧,打开/closuressendfile,没有区别。

从configuration文件运行nginx服务器不在默认位置

我有一个名为default-site的nginxconfiguration文件,如下所示: server { … } 在我的文档文件夹中的某处。 是否可以使用此configuration文件运行服务器,而不是将其放在默认的/usr/local/etc/nginx/nginx.conf ? 我尝试使用-c标志,如下所示: sudo nginx -c ~/Documents/trustfactors/analytics/infra-ansible/roles/nginx/files/default-site 但我得到的错误: nginx: [emerg] "server" directive is not allowed here in /Users/william/Documents/trustfactors/analytics/infra-ansible/roles/nginx/files/default-site:5

Postfix,dovecon,roundcube Cloudflare证书不可信,未知协议(ssl,tls)

我正试图让dovecot / postfix运行encryption。 我创build了这样的证书: 生成自定义自签名证书 对于第6步,我使用了cloudflares Origin证书/私钥(PEM,RSA) 然后我在postfix / main.cf中更新了我的值: myhostname = mail.domain.tld mydomain = domain.tld myorigin = $myhostname mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain mynetworks_style = subnet […] smtpd_use_tls=yes smtpd_tls_security_level = may smtpd_tls_auth_only = yes smtpd_tls_key_file = /etc/postfix/tls/device.key smtpd_tls_cert_file = /etc/postfix/tls/device.crt smtp_tls_CAfile = /etc/postfix/tls/rootCA.pem smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache #smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3 #smtpd_tls_exclude_ciphers = aNULL, DES, […]

用于外部Web应用程序的nginx反向代理

我有一个安装了nginx的AWS EC2实例,我正在尝试为Web应用程序创build一个反向代理。 这是我的* .conf文件 server { listen 8080; server_name MY_EC2_INSTANCE_PUBLIC_IP; access_log /var/log/nginx/webapp.access.log; error_log /var/log/nginx/webapp.error.log; location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://WEBAPP_IP_ENDPOINT/; proxy_read_timeout 90; proxy_redirect off; } } 当我导航到http:// MY_EC2_INSTANCE_PUBLIC_IP:8080我被转发到一个404页面,说这个域没有configuration。 有没有可能做这样的事情? 我期待看到这个网页的内容,但通过我的ec2实例查看它。

configurationNginx的HTTPS

我必须设置一个反向代理redirect到一个内部networking服务器(172.16.0.115),这样我们才能允许networking外的人安全地访问networking服务器。 此服务器是在2012 R2上运行的IIS。 我在一台VM(SRVPRXY01P / 172.16.8.145)上安装了CENTOS和Nginx。 我用这个configuration成功地将httpredirect到172.16.0.115: server { listen 80; server_name SRVPRXY01P; #root /usr/share/nginx/html; access_log /var/log/nginx/proxy-access.log combined; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { proxy_pass http://172.16.0.115/; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 […]

如何为Nginx和Varnish设置ipv6

我在我的nginxconfiguration中有一个上游服务器,指向Varnish监听的端口: upstream abtomorrow_app_server { server 127.0.0.1:6081 fail_timeout=0; } 这适用于ipv4,但我很好奇, 这是足够的ipv6? 我怎样才能正确地testing它? 注意:我已将AAAAlogging添加到域,并正确configuration了AWS(AWS已确认)。 这是我的netstat: netstat -nlp | grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 14812/nginx tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 14812/nginx tcp6 0 0 :::80 :::* LISTEN 14812/nginx tcp6 0 0 :::443 :::* LISTEN 14812/nginx 它似乎是在监听ipv6地址,但是像http://ipv6-test.com/validate.php这样的服务却说web服务器是不可访问的。 有问题的域名是albertatomorrow.ca 谢谢! :d

Nginx的网页cachingtweeking

我试图build立一个NGINX服务器,作为坐在另一台服务器上的底层PHP应用程序的caching服务器。 原则上,事情运作良好,但由于PHP应用程序的某些“不良行为”,我需要对NGINX进行一些调整,但到目前为止我还是失败了。 有这些问题的解决scheme吗? 问题1:PHP应用程序发送“Vary:Accept-Encoding”作为可caching内容的响应头,并导致NGINX针对不同的Accept-Encoding请求头保留不同的caching副本,这是正确的,但不是我想要的performance。 我的需求要求NGINX删除Accept-Encoding请求头,因为它会代理PHP应用程序,并在caching时忽略头。 我已经完成了第一部分的使用: proxy_set_header Accept-Encoding ""; 这个configuration从请求中删除标题,但是不会在caching方面忽略它。 我很清楚proxy_ignore_headers,我可以在下面的设置中使用它,但是解决scheme将忽略Vary头部中的任何头部名称,而不仅仅是Accept-Encoding proxy_ignore_headers Vary; 有没有解决这个问题? 问题2: PHP应用程序正试图设置可caching内容的会话cookie。 我希望NGINX忽略用于caching的Set-Cookie头,还要删除任何可caching内容的响应头Set-Cookie。 为了使NGINX根据我使用的caching忽略Set-Cookie响应头: proxy_ignore_headers Set-Cookie; NGINX不会忽略头,但会将Set-Cookie响应头发送给任何用户。 在NGINX上有解决scheme,我可以根据页面是否被caching来删除标题。 我试图使用if子句来检查$ sent_http_cache_controlvariables,但是似乎如果在响应可用之后语句没有重新运行,所以这样的variables在被评估的时候不会被设置。

设置nginx client_body_buffer_size为web应用程序接受照片上传

在configurationnginx时,哪些因素影响client_body_buffer_size ? 我已经设置为10m的网站,用户上传照片和图像模式(有点像9gag)。 请注意, client_max_body_size也设置为10m 。 总的来说,我的推理是,networking服务器应该接受图像大小为10MB(网站策略)的POST请求 – 因此这两个指令应该是10m 。 这个推理是否正确? 有人可以阐明影响client_body_buffer_size设置的值的因素, client_body_buffer_size典型值(对于我描述的那种Web应用程序)? 如果重要的话,我使用nginx作为反向代理。

在nginx.conf中设置超时

我有两个关于设置我的nginx反向代理服务器的超时值的想法。 Linode的教程build议如下: client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; 然而,Digital Ocean就同一主题提供的一个教程也表明: client_body_timeout 12; client_header_timeout 12; keepalive_timeout 15; send_timeout 10; 而且,前者build议: keepalive_requests 100000; 而另一个优化啧推荐: keepalive_requests 200; 显然,并不是所有的优化指南都是相同的。 这是一个像我这样的意外服务器pipe理员混淆。 我知道基准我的实际环境可以帮助,但我想先从理智的数字开始。 将这些数字设置得非常高还是非常低的优点和缺点是什么? 连接到这个特定的networking应用程序的客户大多有连接问题(移动互联网慢),这意味着也许我应该从一个高数字开始? 或者这不是一个因素? 获得关于这些价值的build议是非常好的。 在保证的情况下,目前我已经在我的conf文件中设置了如下参数。 需要帮助调整他们: client_body_timeout 1m; client_header_timeout 1m; keepalive_timeout 65; send_timeout 30s; keepalive_requests 3000;

Nginx没有提供Perl文件

我在Debian 9上运行Nginx服务器。我的问题是,Nginx在根目录下提供Perl文件,但是它不在别名目录中(我得到403 Forbidden)。 这是我的别名configuration: include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; server { listen 80; server_name www.example.tld example.tld; root /srv/!example.tld/!www; index desktop.pl index.html index.htm core.tom core.pl; location /my_alias { alias /srv/!example.tld/my_alias/!www; location ~ /my_alias/\.pl$ { gzip off; fastcgi_pass unix:/var/run/fcgiwrap.socket; } } location ~ \.pl$ { gzip off; fastcgi_pass unix:/var/run/fcgiwrap.socket; } } 我真的不知道什么是错的。 所有我想要的是在整个服务器(所有别名)上执行Perl文件,理想的是在所有站点(虚拟主机)上执行Perl文件。