Articles of nginx

nginxredirect没有端口

我有一个Nginx的301redirect问题。 它总是通过本地端口redirect到一个URL。 情况如下:网站正在运行Cloudflare,完整的https。 CF将http请求发送到varnish接受它们的服务器。 清漆然后将请求传递给nginx,它与FPM一起处理其余部分。 Nginx运行在8080端口。我在Nginx中创build一个301redirect,就像我通常做的那样: location = /url1 { return 301 /url2; } Nginx然后redirect到URL,但是添加它运行的原始主机名和端口(8080)。 所以我将port_in_redirect设置为在服务器configuration中closures。 那工作一半。 它会将一个http URLredirect到https(不提到端口8080)。 它会redirect一个https URL到http,虽然,循环。 我怎样才能确保这不会发生? 我想知道是否有可能知道Cloudflare也在为请求提供服务。

端口80上的hhvm绑定阻止nginx绑定到该端口

我使用以下server.iniconfiguration在ubuntu14上运行hhvm: server.ini ; php options pid = /var/run/hhvm/pid ; hhvm specific ;hhvm.server.port = 9000 hhvm.server.file.socket=/var/run/hhvm/hhvm.sock hhvm.server.type = fastcgi hhvm.server.default_document = index.php hhvm.log.use_log_file = true hhvm.log.file = /var/log/hhvm/error.log hhvm.repo.central.path = /var/run/hhvm/hhvm.hhbc 我注释了9000端口行,并添加了文件套接字选项。 这个改变后,当我重新启动服务,似乎hhvm似乎绑定在端口80(我试图在端口80上运行nginx)。 我找不到任何hhvm的configuration,它显式绑定在端口80上。关于如何确保hhvm不使用端口80的任何想法。 php.ini中 ; php options session.save_handler = files session.save_path = /var/lib/hhvm/sessions session.gc_maxlifetime = 1440 ; hhvm specific hhvm.log.level = Warning hhvm.log.always_log_unhandled_exceptions = true […]

nginx是否停止发送stream量到无响应的PHP服务器?

我们在AWS上运行一个具有特定设置的网站:一个ELB将负载分割成2个运行nginx的t2.medium实例。 从那里,PHPstream量被分成两个(前端和API)stream,两个stream向我们的PHP服务器的内部ELB。 为了logging,我们有2个前端PHP服务器(t2.medium)和3个PHP PHP服务器(m4.large)。 所有在端口9000上运行相同版本的PHP-FPM。 所有的工作很好,直到前几天。 出于某种原因,尚未确定,PHP API服务器上的stream量就会死亡,只有一次nginx重新启动才能恢复正常。 我们假设我们可能有一些长时间运行的过程,导致PHP服务器变得忙碌起来,并且从这里一路走下坡路。 但是,所有PHP服务器的CPU使用率都是相当稳定的,直到停止响应。 PHP-FPM仍在运行,ngnix服务器上的负载仍然很低。 客户端收到的响应是504,这就是我在nginx错误日志中看到的: 2016/10/04 14:34:25 [error] 17661#0: *2309784 connect() failed (113: No route to host) while connecting to upstream, client: xxx.xxx.xxx.xxx, server: api.mywebsite.com, request: "GET /some/route HTTP/1.1", upstream: "fastcgi://internalip:9000", host: "api.mywebsite.com" nginx.conf worker_processes 4; worker_connections 19000; nginx网站conf location ~ \.php$ { try_files $uri =404; fastcgi_buffer_size 512k; […]

什么原因导致Opcache手动重启

我已经用php-fpm设置opcache,但由于某种原因,它不断手动重新启动。 我没有重新启动,我已经设置强制重启超时时间为2700秒(2小时),所以caching不应该被清除。 什么导致手动重启? Array ( [opcache_enabled] => 1 [cache_full] => [restart_pending] => [restart_in_progress] => [memory_usage] => Array( [used_memory] => 58506120 [free_memory] => 478364792 [wasted_memory] => 0 [current_wasted_percentage] => 0 ) [interned_strings_usage] => Array( [buffer_size] => 16777216 [used_memory] => 5840560 [free_memory] => 10936656 [number_of_strings] => 3946503 ) [opcache_statistics] => Array( [num_cached_scripts] => 1553 [num_cached_keys] => 3015 […]

HAProxyconfiguration

在我能find的所有用例中,HAProxy运行在与内容服务器不同的服务器上,例如: 实例1 – 负载均衡器主机名:haproxy IP:192.168.205.15 实例2 – Web服务器1主机名:webser01 IP:192.168.205.16 实例2 – Web服务器2主机名:webserver02 IP:192.168.205.17 是否有可能在内容服务器上运行HAProxy(和nginx一起)以及configuration如何?

我有一个奇怪的位置configurationnginx

我正在审计我的nginxconfiguration,他们中的很多人都有这个 location ~* \favicon.ico$ { access_log off; expires 1d; add_header Cache-Control public; } 这只是为了favicon.ico文件? 这样做有什么意义吗?

带有服务器指令的nginx映射。 转发http – > https

我有7个服务。 我希望他们自动转发http-> https。 我正在尝试这个,但它不工作: map $http_host $backend { apples.example.com http://127.0.0.1:3006; oranges.example.com http://127.0.0.1:3000; bananas.example.com http://127.0.0.1:3010; pears.example.com http://127.0.0.1:3012; dragonfruit.example.com http://127.0.0.1:3014; peaches.example.com http://127.0.0.1:3002; tomatos.example.com http://127.0.0.1:3016; } # All services (except button) forward HTTP -> HTTPS server { listen 80; return 307 https://$http_host$request_uri; } 我误解了一些东西,因为其中一个服务不匹配。 http://apples.example.com正在转发到https://peaches.example.com 我正在运行这个testing: sudo service nginx restart && wget http://apples.example.com/ –no-check-certificate 它正在返回: –2016-10-05 20:07:37– http://apples.example.com/ […]

Nginx反向代理。 1个SSL证书。 多个域名。 我需要SSL SAN Cert吗?

我有一个Nginx反向代理设置,并且可以正常使用SSL证书,包括标准和多SAN。 如果我设置了一个虚拟服务器,比如带有标准SSL的mysite.com,一切都很好。 如果我在浏览器中向域名mysite.co.uk添加相同的虚拟服务器,则会收到错误消息,说明该网站的证书无效。 我明白为什么我得到这个错误消息,我想知道的是我可以使用Nginx将mysite.co.uk转发到mysite.com以避免在浏览器中的错误信息? 我已经尝试在Nginx上重写,但我不认为这是做到这一点。 我不能在DNS级别执行此操作,因为我的客户端DNS不允许这样做。 这不仅仅是一个域,有很多,我需要保持低成本,而不是购买SAN SSL。 在此先感谢您的帮助。

警告:池www看起来很忙(您可能需要增加pm.start_servers或pm.min / max_spare_servers)

我正试图解决这个问题在基于VPS Debian的8GB内存 – 2vCores 我正在使用nginx和php7-fpm 检查/var/log/php7.0-fpm.log我有这么多的行 WARNING: [pool www] seems busy (you may need to increase pm.start_servers, or pm.min/max_spare_servers), spawning 16 children, there are 0 idle, and 7 total children 这是我的/etc/php/7.0/fpm/pool.d/www.conf pm = dynamic pm.max_children = 10 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 ;pm.process_idle_timeout = 10s; pm.max_requests = 200 任何人都可以帮我解决这个问题? 我已经增加了价值 pm.max_children […]

使用Nginx的反向代理Nextcloud失败

我一直在寻找这个相当长的一段时间,我没有find任何东西。 我通过各种论坛search,做了一些谷歌search,他们什么都没有。 我有一个服务器在Docker容器中运行我所有的应用程序(例如Plex,Nextcloud等)。该服务器还有一个安装了Wordpress的Nginx Docker容器。 现在,我们说内部networking中指向Nextcloud的IP是192.168.0.200:9000 。 我已经validation了,当我使用直接的IPlogindocker工程。 但是,在设置Nginx代理的时候,事情就有些失控了。 我也有Cloudflare保护,当我设置Cloudflare,它连接到docker罚款。 (假设域名是cloud.abc.com )但是,有一个内联脚本错误: Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval'". Either the 'unsafe-inline' keyword, a hash ('sha256-Vv06cSNCZln6C3GDj3jl163TqpSEik9IA1SYp3knJ/E='), or a nonce ('nonce-…') is required to enable inline execution. 当我禁用Cloudflare时,当我尝试连接时,Chrome会出现ERR_CONNECTION_REFUSED错误。 我猜测SSL的问题,但我没有networking的经验,所以我迷失在这里。 这是我在Nextcloud中的config.php: <?php $CONFIG = array ( 'memcache.local' => […]