在一个项目中,我有非常大的nginxconfiguration与大量的冗余线。 目前的状态如下所示 location ~ /loc1/ { common rules; } location ~ /some/other/location/ { common rules; } location ~ /yet/anotherone { common rules; } etc ….. 我想要的是有一个通用的规则模板和位置列表的分离方式。 在其他相关的问题中,人们使用正则expression式来匹配像这样的几个位置 location ~ (/loc1/|/some/other/location/|/yet/anotherone) { common rules; } 在我的情况下,这将导致一个巨大的线,这将是非常难以维持。 有没有另一个更干净的方法来做到这一点 非常感谢你。
根据phpinfo: 加载的configuration文件: /etc/php5/fpm/php.ini # grep expose_php /etc/php5/fpm -R /etc/php5/fpm/php.ini:expose_php = Off /etc/php5/fpm/pool.d/www.conf:php_flag[expose_php] = off # curl -I https://MyHost.loc/i.php | head | grep X-Powered-By X-Powered-By: PHP/5.5.9-1ubuntu4 有人可以在Ubuntu 14.04中确认这一点吗? 任何想法如何摆脱X-Powered-By?
我试图设置主机名来演示一个糟糕的SSLconfiguration,我有一些问题。 我可以指定一些不好的密码套件,但是nginx似乎忽略了协议select。 server { listen 443 spdy ssl; keepalive_timeout 70; server_name example.co.uk; client_max_body_size 10M; ssl_certificate /path/to/ssl.crt; ssl_certificate_key /path/to/ssl.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; … } server { listen 443 spdy ssl; keepalive_timeout 70; server_name weak.example.co.uk; client_max_body_size 10M; ssl_certificate /path/to/weakssl.crt; ssl_certificate_key /path/to/weakssl.key; ssl_protocols SSLv3; … } Nginx可以使用我指定的不同密码套件,但是似乎使用了第一个服务器模块的协议,weak.example.co.uk具有TLSv1 / 1.1 / 1.2并且不支持SSLv3。 是否可以为每个服务器块指定不同的协议?
这里是我的php-fpmconfiguration是: location @site { fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root/index.php; fastcgi_intercept_errors on; error_page 404 /404; } 由于启用了fastcgi_intercept_errors ,当我的PHP路由器返回404时,Nginx将redirect到/404 。 很好 。 但是由于/404是由我的PHP应用程序生成的,而且我的PHP应用程序正确设置了404响应代码,那么Nginx将尝试再次处理该错误! (这明显以循环结束) 有针对这个的解决方法吗?
没有深入到杂草,Nginx迫使我的手,以通过虚幻和map指令完成一些魔术。 是否有一个优雅的(相对)解决scheme来跨多个定义调用共享一个variables,它允许每个定义调用将其数据附加到全局variables? 在软件中,这将被称为单身。 – 杂草 – Nginx有一个map指令,它决定了哪个上游服务器池应该被传递,如下所示: map $http_host $upstream_pool { hostnames; blog.example.com blog_example_com; repo.example.com repo_example_com; default example_com; } 如您所见,对blog.example.com的任何请求都将传递到blog_example_com上游服务器池(通过proxy_pass )。 问题是map指令的语法是它只能包含在主要的http块(nginx.conf)中,而vhost特定的指令(如upstream和location可以包含在vhostconfiguration的server块中。 我的nodes.pp清单看起来像这样: service-a-1.example.com inherits project_dev { nginx::vhost { 'mothership': } nginx::vhost { 'mothership_blog': } nginx::vhost { 'repo': } } 正如你所看到的,在一个成功的木偶运行之后,我应该在/etc/nginx/vhost.d/目录中得到3个不同的vhostconfiguration文件。 我遇到的问题是,为了使map指令工作,我需要知道哪些虚拟主机已经加载,所以我可以将他们各自的上游id添加到我在主configuration中定义的map指令中: /etc/nginx/nginx.conf http块中的/etc/nginx/nginx.conf (其中只能有一个)。 – 我曾尝试过 – – 我有一个global.pp文件,它做了一些“引导”,并在这个文件中添加了一个$singleton = ''语法,然后在nginx :: vhost定义中,我添加了这个语法: $tpl_upstream_pool_labels […]
我们的应用程序在高负载下变得反应迟钝,等待时间更长。 进程使用率exception低(每个进程约15%的CPU利用率,我们的应用程序运行8个进程)。 Nginx错误日志输出显示了一些这些: 2014/12/04 03:39:31 [crit] 24383#0: *2008067 connect() to 127.0.0.1:4567 failed (99: Cannot assign requested address) while connecting to upstream, client: 108.162.246.229, server: example.org, request: "GET /socket.io/?EIO=3&transport=polling&t=1417682366937-11501 HTTP/1.1", upstream: "http://127.0.0.1:4567/socket.io/?EIO=3&transport=polling&t=1417682366937-11501", host: "example.org", referrer: "https://example.org/unread" 我所看到的 ss -tan | grep TIME-WAIT | wc -l输出 ss -tan | grep TIME-WAIT | wc -l ss -tan | […]
文档说这个: 当且仅当在当前级别上没有定义add_header指令时,这些指令才从前一级inheritance。 我的问题是,我有几个location块,我想要caching,就像这样: add_header X-Frame-Options SAMEORIGIN; add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;"; location ~ ^/img/(.*)\.(png|jpg|jpeg|gif|bmp)$ { expires 1w; add_header Cache-Control public; } 但是这样会让我失去在块之外声明的所有头文件。 所以显然唯一的办法是在每个位置块上重复这些标题,例如: add_header X-Frame-Options SAMEORIGIN; add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;"; location ~ ^/img/(.*)\.(png|jpg|jpeg|gif|bmp)$ { expires 1w; add_header Cache-Control public; add_header X-Frame-Options SAMEORIGIN; add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;"; } 看起来不正确。 有任何想法吗?
我想弄清楚如何禁用TLSv1和1.1 Nginx,并且只允许1.2上的连接。 这是为了testing的原因,而不是在生产中使用,对于我的生活,我不明白为什么Nginx不会让我这样做。 Nginx SSLconfiguration: ssl on; ssl_protocols TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers ECDH+AESGCM256:DH+AESGCM256:ECDH+AES256:!aNULL:!MD5:!kEDH; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; add_header Strict-Transport-Security "max-age=262974383; includeSubdomains;"; add_header X-Frame-Options DENY; add_header X-Content-Type-Options nosniff; ssl_stapling on; ssl_stapling_verify on; resolver 8.8.8.8 8.8.4.4 valid=300s; 但由于某种原因,Nginx仍然在谈判1.0和1.1的连接。 难道我做错了什么? 我在OpenSSL 1.0.1f的Ubuntu Server 14.04LTS上使用Nginx 1.7.10。
我正在尝试将Nginx设置为S3上托pipe的静态html / js webapp的代理。 我阅读了大量的教程和post,如果我的存储桶被设置为公开,我可以使其工作。 我需要Nginx作为代理的原因是我不希望我的存储桶公开。 遵循本指南,我添加了这个 GitHub仓库中的set-misc-nginx-module。 额外的模块通过提供AWS密钥和AWS秘密,为桶的每个对象构build经过validation的S3请求。 我重新编译了Nginx,并设法允许它访问受保护的存储桶。 问题是,我无法呈现HTML,基本上我正在与我试图代理桶的XML内容。 这是Nginx的configuration文件 server { listen 80; server_name [MY_DNS]; location * { set $bucket '[MY_BUCKET]'; set $aws_access '[MY_AWS_KEY]'; set $aws_secret '[MY_AWS_SECRET]'; set $url_full "$1"; set_by_lua $now "return ngx.cookie_time(ngx.time())"; set $string_to_sign "$request_method\n\n\n\nx-amz-date:${now}\n/$bucket/$url_full"; set_hmac_sha1 $aws_signature $aws_secret $string_to_sign; set_encode_base64 $aws_signature $aws_signature; resolver 172.31.0.2 valid=300s; resolver_timeout 10s; proxy_http_version 1.1; proxy_set_header […]
我有nginx,并希望它来validation客户端证书。 所以我买了服务器的商业证书,而非客户的商业证书。 基本上我已经用easy-rsa脚本生成了客户端证书。 连接与客户端证书validation禁用按预期工作。 连接“ssl_verify_client on” 代码400失败,没有错误信息或访问日志。 nginx -V输出: nginx version: nginx/1.8.0 built with OpenSSL 1.0.2a 19 Mar 2015 TLS SNI support enabled configure arguments: –prefix=/etc/nginx –conf-path=/etc/nginx/nginx.conf –sbin-path=/usr/bin/nginx –pid-path=/run/nginx.pid –lock-path=/run/lock/nginx.lock –user=http –group=http –http-log-path=/var/log/nginx/access.log –error-log-path=stderr –http-client-body-temp-path=/var/lib/nginx/client-body –http-proxy-temp-path=/var/lib/nginx/proxy –http-fastcgi-temp-path=/var/lib/nginx/fastcgi –http-scgi-temp-path=/var/lib/nginx/scgi –http-uwsgi-temp-path=/var/lib/nginx/uwsgi –with-imap –with-imap_ssl_module –with-ipv6 –with-pcre-jit –with-file-aio –with-http_dav_module –with-http_gunzip_module –with-http_gzip_static_module –with-http_realip_module –with-http_spdy_module –with-http_ssl_module –with-http_stub_status_module –with-http_addition_module –with-http_degradation_module –with-http_flv_module –with-http_mp4_module […]