Articles of nginx

Nginx与Keepalived

我有两个nginx服务器,它们处理1)反向代理和2)两个Web服务器上的负载平衡。 由于我无法提供任何nginx机器IP给客户,所以我想用VIP保持在2个Nginx机器的顶部,它也检查Nginx的故障切换。 我所取得的成就1)在2台机器上成功安装了nginx,所以当我点击任何nginx服务器IP时,我就能看到应用程序的网页。 即使我testing了失败,它工作正常。 2)我已经在这两台机器上安装了keepalived,并尝试使用以下configuration生成VIP vrrp_script chk_nginx { script "killall -0 nginx" interval 2 } vrrp_instance VI_1 { interface eth0:1 state MASTER virtual_router_id 51 priority 100 unicast_src_ip server1_ip unicast_peer { server2_ip } virtual_ipaddress { VIP } track_script { chk_nginx } } – >所以在这里,当我打网页浏览器中的VIP我有以下错误本网站无法到达 VIP拒绝连接。 尝试:检查连接检查代理和防火墙 不知道我在这里错过了什么。 有人可以帮我解决这个问题。所以根据我的理解,当我打到VIP我应该看到应用程序的网页? 问候VG

NGINX – 通过S3提供静态文件或故障恢复到本地服务器

我将nginx作为一个负载均衡器(使用caching),并将请求传递给一些AWS EC2实例来服务这些页面。 当谈到服务静态资源,我想通过AWS S3(这是工作正常)尝试和服务,但如果该文件返回403/404等,我想请求继续通过一个EC2实例送达。 我现在有这个: location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { try_files $uri @s3; } 它寻找静态文件,然后通过S3服务,这是好的…但如何修改这个或我的@ s3的位置回落到请求的正常proxy_pass如果文件没有退出S3? 谢谢

如果使用特殊的头部设置,则使用proxy_pass,否则使用Nginx中的静态文件

在Nginx中有没有一种方法可以始终为root指定的静态文件提供服务,除了根据某些条件(即指定的头部)匹配请求的情况,在这种情况下,它将被传递到上游?

在Nginx日志中显示日志级别

这下面是django日志条目, INFO 2017-06-13 00:30:55,062 views 33096 140505817540352 https://play.google.com/store/apps/details?id=com 这里显示日志条目中的日志级别INFO 。 有什么办法可以在nginx日志中显示这个日志级别吗?

PHP文件下载页面加载而不是执行 – NGINX

我已经在根目录中build立了一个与我们的实际域一起的子域。 在根目录下的两个文件夹如下所示: domain.com sub.domain.com 当去到域名(已经存在)事情工作正常。 当去sub.domain.com(这是一个WordPress的安装) index.php文件只是下载和页面不加载或执行。 在我的etc/nginx/sites-available/sub.domain.com.conf我有: server { listen 80; root /var/www/sub.domain.com; index index.php index.html index.htm; server_name sub.domain.com; location / { try_files $uri $uri/ =404; } } 我记得重新启动nginx服务器,但是,我们使用php-fpm,所以我不确定这是否可能是相关的。 它必须与PHP相关,因为当replace基本index.html文件的wordpress安装时,页面按预期加载。 有谁知道什么可能会导致这种行为?

在nginx + varnish + SSL中错误太多的redirect

我有一个集群基础结构。 我使用nginx在清漆前面进行SSL终止。 varnish的后端是apache web服务器。我也有一个haproxy作为负载平衡器,它直接发送HTTPS请求到nginx,并直接发送HTTP请求到清漆服务器。 问题是,当我启动nginx时,一切都可以,但是在浏览ssl网站的浏览器中,我得到了too_many_error_redirects! 我认为我的configuration有问题,但我不知道哪个configuration(nginx或varnish)是这个错误的原因。 当我直接向Web服务器转发请求时,一切正常,因此可能是清漆configuration有问题。 这里是我的configuration: Nginx config:domain_name.conf server { listen 443; server_name mydomain.com; ssl on; ssl_certificate /etc/nginx/ssl/domain_name_bundle.pem; ssl_certificate_key /etc/nginx/ssl/my_key.key; ssl_session_cache shared:SSL:20m; ssl_session_timeout 10m; ssl_prefer_server_ciphers on; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS +RC4 RC4"; add_header […]

LetsEncrypt错误:无法设置,让我们encryption

编辑: Nginxconfiguration: server { server_name selftestcheck.com www.selftestcheck.com; access_log /var/log/nginx/selftestcheck.com.access.log rt_cache_redis; error_log /var/log/nginx/selftestcheck.com.error.log; root /var/www/selftestcheck.com/htdocs; index index.php index.html index.htm; include common/redis-php7.conf; include common/wpcommon-php7.conf; include common/locations-php7.conf; include /var/www/selftestcheck.com/conf/nginx/*.conf; location '/.well-known/acme-challenge' { root /var/www/domain/htdocs; } } 这个问题也许之前已经被问过了,但似乎没有答案,所以我想试着回答一下,因为很多人似乎都忍受了这个问题。 这就是问题: 我运行“sudo ee站点创build域 – wpfc –letsencrypt”或“sudo ee站点更新域–letsencrypt” 我得到这个错误: “要解决这些错误,请确保您的域名input正确,并且该域名的DNS Alogging包含正确的IP地址。” 几个月前,我可以做sudo ee网站创build域 – wpfc –letsencrypt,一切都将工作得很好。 现在突然间,我用ee创build的每个站点都有这个https问题。 为什么?! 无论如何,基本上我认为每个人都需要弄清楚发生了什么事情: 这是tail -n100 /var/log/ee/ee.log […]

Nginx的proxy_path根重写到域/path

这在proxy_pass上可能是这样的吗? location / { proxy_pass http://example.com/path/; } 要求将所有来自http://example.com的请求指向http://another-example.com/path

设置letsencrypt在我的nginx服务器在centos 6

所以,我正在关注为我的服务器设置ssl的这篇文章 。 但是我在configurationnginx的.conf文件时感到困惑。 这是我的conf文件: user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } 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; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } 但是,如何configuration它来创buildconfiguration,将端口80(http)请求转发到端口443(https)的侦听器,并包含适当的path?

WordPress 504 Gateway在安装和添加用户时超时

我的WordPress安装有问题。 我正在VPS服务器上运行它。 我安装了我自己的LEMP堆栈。 当运行WordPress安装时,在最后一步之后,加载最后需要一些时间,最后出现504 Gateway Time-out错误。 但该网站已安装,我可以login到pipe理面板。 在pipe理面板里面,当我尝试创build一个用户时,同样的事情发生了。 但用户被创build。 奇怪的是,即使我勾选了发送邮件的方框,用户也不会收到包含详细信息的电子邮件。 我的nginx错误日志如下所示: PHP message: WordPress database error Table 'tkdpw39sna2.d3gsO9d_options' doesn't exist for query INSERT INTO `d3gsO9d_options` (`option_name`, `option_value`, `autoload`) VALUES ('rewrite_rules', '', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`) made by wp_install, flush_rewrite_rules, WP_Rewrite->flush_rules, update_option, add_option" while reading upstream, […]