Articles of nginx

nginx不cachingwordpress网站

我有一个网站设置使用nginxcaching。 以下是详细信息: fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=MYAPP:100m inactive=60m; fastcgi_cache_key "$scheme$request_method$host$request_uri"; server { listen 80 default_server; listen [::]:80 default_server; set $no_cache 0; if ($request_method = POST) { set $no_cache 1; } if ($query_string != "") { set $no_cache 1; } if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") { set $no_cache 1; } if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { set $no_cache 1; […]

FastCGI发送stderr:“主要脚本未知”+ Owncloud

我遇到了一个奇怪的错误,我的nginx / php5-fpmconfiguration。 我已经在自己的云论坛上发布了这个问题,并且问了nginx论坛,但是他们不知道。 当我searchserverfault时,关于这个主题的build议并不直接适用于我的问题,因为他们都共享一个错误configuration的位置块,我认为,在这里是不是这种情况(我从自己的云文档直接configuration)。 那么问题是什么? 我的nginx error.log填充了这些: "FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: MY IP, server: MY DOMAIN, request: "GET /core/img/actions/history.svg HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "MY HOSTNAME/DOMAIN", referrer: "MY DOMAIN" Owncloud运行在一个子目录/srv/www/owncloud,根目录指向/srv/www 。 如果我把相同的configuration指向root /srv/www/owncloud ; 同样的错误是造成,但这次它读取: FastCGI sent in stderr: "Primary script unknown" while reading response […]

将现有的通配符SSL证书添加到Amazon EC2 Nginx

我试图将预先存在的通配符SSL证书添加到Amazon EC2上的单个Ubuntu实例,其中networking服务器是Nginx,并且运行一个子域。 我有 – 从提供证书的原始供应商 – 名为private.key,selfsigned.crt和ssl-shared-cert.inc的文件。 我已经将这些file upload到了/ etc / nginx / ssl(这是我创build的一个新文件夹)的EC2。 我以前在Heroku上使用过相同的文件,虽然这个过程似乎是非常具体的。 他们也在我们的主域( https://wwww.minnpost.com )上使用,但是我并没有参与设置,因为我相信我们的托pipe供应商是为我们做的。 ssl-shared-cert看起来像这样: SSLEngine On SSLProtocol all -SSLv2 -SSLv3 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW SSLCertificateFile "/path/to/selfsigned.crt" SSLCertificateKeyFile "/path/to/private.key" 在我的EC2实例上,我将网站的configuration更改为: server { listen 8080; listen 443 ssl; server_name subdomainurl; ssl_certificate /etc/nginx/ssl/selfsigned.crt; ssl_certificate_key /etc/nginx/ssl/private.key; root path; … } 当我运行sudo nginx -t我得到以下内容: nginx: the configuration […]

如何将GeoIP HTTP请求标头传递给Apache的后端?

我正在使用nginx将HTTP请求代理到在Docker容器( cbeer / piwik )中的Apache 2.4(mod_php5)范围内运行的PHP应用程序。 +——————————+ | Docker Container | +——-+ | +——–+ +—–+ | | nginx |———–>|->| apache |———>| php | | +——-+ proxy_pass | +——–+ mod_php5 +—–+ | +——————————+ PHP应用程序是Piwik 2.16。 我使用nginx注入GeoIP HTTP标头: proxy_set_header GeoIP-Addr "$remote_addr"; proxy_set_header GeoIP-Country-Code "$geoip_country_code"; proxy_set_header GeoIP-Country-Name "$geoip_country_name"; proxy_set_header GeoIP-Continent-Code "$geoip_city_continent_code"; proxy_set_header GeoIP-Region-Name "$geoip_region_name"; proxy_set_header GeoIP-Region "$geoip_region"; proxy_set_header […]

将所有urlredirect到SSL,但不包括X.

我在Vesta CP上运行NGINX。 有两个单独的文件nginx.conf和snginx.conf 。 每个服务器都有一个服务器块。 我将整个站点redirect到SSL。 为此,我添加一个return 301 https://example.com$request_uri; 到nginx.conf ,然后我完全configuration了sningx.confcaching和位置块等等。 我有一个域是部分SSL /非SSL。 在这些文件中,我不是301,而是我301的位置块,像这样: location ~ ^/(wp-login.php|wp-admin|wp-login|shop|product|my-account|checkout-2|order-pay|order-received|add-payment-method|cart) { return 301 https://domain.com$request_uri;} 而在SSL块我排除: location ~ ^(?!/(wp-login.php|wp-admin|wp-login|shop|product|my-account|checkout-2|order-pay|order-received|add-payment-method|cart)) { return 301 http://sergerpepper.com$request_uri;} 我需要在SSL和非SSL上都有一个可用的URL,其他的都在SSL上。 这个url是网站地图。 所以这两个将工作: http://example.com/sitemap_index.xml https://example.com/sitemap_index.xml 但是任何其他的URL只能在SSL上。 通过我以上的redirect方法,我可以在HTTP上指向一个URL,或者将它排除在HTTPS之外,但不能同时指向两者。

NGINX:如何configurationTCP上游的相互authentication?

我感兴趣的关于TCP上游SSL终止的特性。 我正在评估NGINX开源和NGINX Plus。 我们有一个应用程序接受来自客户端的TLS消息(TCP)。 用NGINX,我想在NGINX终止TLS,然后NGINX会把解密后的数据包转发给应用程序。 请注意我的应用程序不会通过HTTP接收消息,而是通过TCP(因此HTTP(S)相关模块对我的用例无效)。 客户端 – (TLS) – > NGINX – (解密) – >应用程序 我已经configurationNGINX进行TCP负载均衡(Non-SSL)。 为此,我必须使用以下两个模块构build源代码: ngx_stream_core_module ngx_stream_ssl_module 现在,我想在NGINX和客户端之间启用SSL的相互authentication。 我看到这个文档谈到服务器端身份validation(客户端validation服务器的证书),但我无法findconfiguration相互身份validation(客户端和服务器都validation对方的证书)的步骤。 你能帮我吗? 在“ngx_stream_ssl_module”中我找不到任何提及客户端证书的选项。 以下是我的nginx.conf的内容: stream { server { listen *:5222 ssl; proxy_pass backend; ssl_certificate /usr/local/nginx/certs/server.crt; ssl_certificate_key /usr/local/nginx/certs/server.key; ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers HIGH:!aNULL:!MD5; ssl_session_cache shared:SSL:20m; ssl_session_timeout 4h; ssl_handshake_timeout 30s; } upstream backend { […]

Nginx包含的指令没有效果

目标: 从我的VPS服务几个低stream量域(主要是静态内容)。 目前,我在FreeBSD下使用Nginx。 问题: 我的include声明似乎完全被忽略。 即使我把乱码放在一个包含的.conf文件中, sudo nginx -t说一切都很好。 因此,我的所有域名都提供相同的默认login页面,只有直接访问服务器的IP地址才能find相应的默认login页面。 如果我访问http://example.com/example.com/html/ ,则会出现我要在http://example.com显示的页面。 我也可以访问http://www.example.com/domain2.com/html/查看http://domain2.com 。 我错过了什么让所有的网站去同一页? 文件: /usr/local/etc/nginx/nginx.conf user www; worker_processes 1; error_log /var/log/nginx/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; access_log /var/log/nginx/access.log; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; #Setup multiple […]

无法访问计算引擎的外部IP

我build立了一个谷歌计算引擎实例,并安装了nginx,现在nginx正在侦听端口80.我有一个静态外部IP分配给我的实例,我只是不能访问我的外部IP地址。 为什么这一定很难? 所有的教程只是说: 安装nginx并转到你的外部ip,你应该到达nginx的欢迎界面 我为http / https设置防火墙规则,但没有任何工作。 这里有一些东西要看: nginx服务器configuration: listen 80; listen [::]:80; server_name example.com; root /var/www/example.com; index index.html; location / { try_files $uri $uri/ =404; } 实例的屏幕截图: 运行nginx: tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3490/nginx tcp6 0 0 :::80 :::* LISTEN 3490/nginx 我试图去: 104.196.111.24但它只是说safari failed to open the page 运行ifconfig返回这个: docker0 Link encap:Ethernet HWaddr […]

nginx – 多久访问特定的文件或path?

我正在寻找一个命令/行来获取信息从Web服务器访问特定文件/path的频率。 (来源:nignx的默认访问日志) 它应该检查所有日志(当前和压缩的日志),并从特定文件/path的日志文件中返回一个或多个entrys。 原因:我想从他的死文件中清除旧的商业网站空间。 许多文件被用于多年前用于外部使用。 (如通讯,列表)。 其他似乎是重复的,只能用于老pipe理员的testing目的。 附加信息: 操作系统:Debian Jessie(x64) 服务器:nginx / 1.6.2 位置:/ var / logs / nginx / 压缩日志文件:gzip 文件: 2825674 | myDomainName_access.log 3895051 | myDomainName_access.log.1 106353 | myDomainName_access.log.2.gz 244729 | myDomainName_access.log.3.gz 143118 | myDomainName_access.log.4.gz 55763 | myDomainName_access.log.5.gz 示例INPUT 你必须进入你的domain.tld的根目录并input以下命令: (只是一个非常简单的例子) user@host:/var/www/domain.tld# filesInLogCheck /var/logs/nginx/domain-access.* subfolder/index.php OUTPUT xxxx – – [07/Mar/2016:10:13:29 +0100] "/subfolder/handle.php HTTP/1.1" […]

食谱yum找不到食谱epel

我有nginx食谱麻烦..它依赖于yum-epel。 出错: “厨师::例外:: RecipeNotFound 找不到菜谱食谱yum“ $ knife cookbook show nginx nginx 2.7.6 2.7.5 2.7.4 1.8.0 $ knife cookbook show yum-epel yum-epel 0.6.6 0.6.0 $ knife cookbook show yum yum 3.10.0 3.6.0 3.5.4 3.5.3 3.5.2 一直在环顾四周,看起来像: yum食谱(3.X)的主要上游版本将yum :: epel食谱移至新的yum-epel食谱。 但找不到应用的解决方法。 我正在使用berks来解决食谱的依赖。 任何帮助深表感谢。 提前致谢。