Articles of nginx

如何减less“连接”时间的请求

我试图优化网站的速度,在这个过程中,我发现。 每次请求页面时都会产生大约620毫秒的连接时间。 详细信息请参见下面的截图 这是持久的。 有什么办法可以减less这个时间吗? 可能的原因是什么? 这是因为SSL吗? 本网站仅作为https://www.winni.in访问 或者这是DNS的问题? 截至目前,我正在使用Godaddy DNS。 切换到AWS Route 53会带来什么好处。 我使用nginx服务器作为Apache Tomcat的代理。

如何使用nginx中的if语句执行多个redirect

所以我的问题是一半SEO的一半技术:我有很多链接redirect,而不是一个接一个地做我的自我: 有没有办法写一个这样的重写规则(这是纯粹的小说,不能在nginx上使用) rewrite /america/(.*)/ http://www.example/nort-america/$1/ permanent; if 500 rewrite /america/(.*)/ http://www.example/south-america/$1/ permanent; 所以这个想法是redirect到一个特定的链接,如果redirect失败尝试其他链接。 这是可能的,而且这是SEO友好?

Nginx重写文件名为目录

我想重写一个文件名membership-list.html作为根域上的一个目录作为membership-list/ 。 我在我的configuration文件中有这个: location = ^/membership-list.html { rewrite ^/membership-list.html ^/membership-list/ redirect; } 我周围search,找不到任何有关从文件redirect到目录名称的信息。

fail2ban:正则expression式来阻止\ x00请求?

每隔一段时间我的服务器closures,当我检查我的nginx日志时,我通常会看到类似这样的内容: 78.37.54.31 – – [20/Apr/2016:20:58:51 +0300] "\x00\x00\x00TZ\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x04\x010I\x00\x00\x00\x00\xFC\x01\xA8\xC0\x00!\x00\xFDk\x00\x00\x00\x00\x00\x00\x00\x00" 400 166 "-" "-" 89.169.219.212 – – [21/Apr/2016:11:37:22 +0300] "\x00\x00\x00 c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" 400 166 "-" "-" 我使用DigitalOcean文章推荐的默认推荐configuration安装了fail2ban,但是它并没有阻止这些扫描程序偶尔会超载我的服务器。 安装naxsi不是我现在的select。 任何人都可以帮助我为fail2ban形成正确的正则expression式规则? “apache-badbots”和“apache-wootwoot”监狱(可以很容易地search)没有为我工作。

我试图用fail2ban来对付/xmlrpc.php

我得到了一吨失败的访问失败吨: 185.103.252.174 – – [28/Apr/2016:15:09:16 -0400] "POST /xmlrpc.php HTTP/1.1" 499 0 "-" "Googlebot/2.1 (+http://www.google.com/bot.html)" 173.246.56.51 – – [28/Apr/2016:15:09:17 -0400] "POST /xmlrpc.php HTTP/1.1" 499 0 "-" "Googlebot/2.1 (+http://www.google.com/bot.html)" 185.103.252.173 – – [28/Apr/2016:15:09:17 -0400] "POST /xmlrpc.php HTTP/1.1" 499 0 "-" "Googlebot/2.1 (+http://www.google.com/bot.html)" 23.226.36.2 – – [28/Apr/2016:15:09:17 -0400] "POST /xmlrpc.php HTTP/1.1" 499 0 "-" "Googlebot/2.1 (+http://www.google.com/bot.html)" 23.226.36.2 – […]

允许SELinux,Nginx读取本地文件并进行出站连接

我是一个使用CentOS 7,nginix和php-fpm的服务器的新pipe理员。 有一个Web表单需要读取本地文件(prod.pem),然后build立一个出站连接: gateway.push.apple.com:2195 gateway.sandbox.push.apple.com:2195 在audit.log中,我看到以下两个条目: type=AVC msg=audit(1465918007.693:406): avc: denied { read } for pid=1796 comm="php-fpm" name="prod.pem" dev="dm-0" ino=19554 type=SYSCALL msg=audit(1465918007.693:406): arch=c000003e syscall=2 success=no exit=-13 a0=7fff2ee13570 a1=0 a2=1b6 a3=24 items=0 ppid=1213 pid=1796 auid=4294967295 uid=997 gid=996 euid=997 suid=997 fsuid=997 egid=996 sgid=996 fsgid=996 tty=(none) ses=4294967295 comm="php-fpm" exe="/usr/sbin/php-fpm" subj=system_u:system_r:httpd_t:s0 key=(null) 我的/etc/selinux/config : SELINUX=enforcing SELINUXTYPE=targeted 我如何configurationSELinux以允许读取文件并进行出站连接? 我也想确保这些在重新启动时保留。

configurationnginx发送HTTP正文的页眉和页脚的响应

我在文件夹/memos/items/有一个备忘录集合单个备忘录用于包含一个HTML标头部分的SSI包含语句,直到包括开头的<body> ,随后是备忘录内容的HTML代码,最后还有一个SSI包含了包含closuresHTML文档代码的页脚声明,如下所示: <!–# include file="/memos/header.html" –> Dies ist ein <i>Testeintrag</i>. <blockquote> Man soll den Tag nicht vor dem Abend loben </blockquote> <!–# include file="/memos/footer.html" –> 这工作得很好,但我不喜欢单个项目文件中的SSI语句。 我宁愿指示nginx自动为页眉和页脚提供类似的configuration location ~ /memos/[\w-]+$ { sendfile /memos/before.html; sendfile $request_filename; sendfile /memos/after.html; } 这可能吗? 是否有一个nginx模块提供一个指令sendfile工作方式sendfile ? 优点是: 包含项目的文件夹只包含纯粹的内容,没有额外的指令。 当提供“search”function时,该文件夹因此可以被grep 。 避免冗余(“包含”页眉和页脚的说明只存在一次,而不是每个重复的文件。 编辑(2016/07/01) 同时,通过简单地改变视angular,我发现了SSI解决scheme具有上述优势(即仅提供内容的项目文件,没有ssi标签):在每个单独的项目文件中,不包括页眉和页脚,而是包含项目文件在一个主模板中。 受nginx网站上的提议的启发; 我configuration location /memos/ { ssi on; […]

当请求来自powershell攻击时,fail2ban规则不起作用

我有一个情况,来自摩尔多瓦的一些知识产权每天都会发现我的基本身份validation凭借某种types的蛮力攻击。 但是我有一个规则fail2ban应该避免这种情况。 当我尝试使用VPN时,它会起作用。 三次尝试后触发fail2ban的请求示例。 我的要求 2016/07/14 15:10:54 [error] 13937#0: *55700 user "engineer" was not found in "/usr/local/nginx/.htpasswd", client: 146.185.31.214, server: localhost, request: "GET / HTTP/1.1", host: "www.mysite.pt" 问题是,来自黑客IP的请求不会触发fail2ban,我不知道为什么。 唯一的区别是referrer:你可以看到。 2016/07/14 01:54:31 [error] 13913#0: *42558 user "engineer" was not found in "/usr/local/nginx/.htpasswd", client: 194.28.112.51, server: localhost, request: "GET / HTTP/1.1", host: "www.mysite.pt", referrer: "http://www.mysite.pt/ /etc/fail2ban/filter.d/nginx-http-auth.conf [Definition] […]

Nginx作为运行WordPress的Apache服务器的代理

我正在面对一个类似的问题,在这里我使用Nginx作为运行WordPress的Apache服务器(Ubuntu)的代理。 网站的内部链接都给301本地主机redirect。 例如,链接: wwww.example.com/internal-linkredirect到localhost/internal-link ,它给出了错误404。 Apache的configuration如下: <VirtualHost *:80> <Directory /var/www/html> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all Require all granted </Directory> ServerAdmin [email protected] ServerName example.com ServerAlias www.example.com ServerAlias *.example.com DocumentRoot /var/www/html … Nginxconfiguration文件如下: server { # Where IP is server IP and example is the domain name listen IP:80; server_name static.example.com; […]

使用nginx允许端口8081上的SSL连接

我有一个问题,以访问https 8081端口。 在这里你可以在nginx中find我的configuration: server { listen 443 ssl default_server; server_name _; ssl on; ssl_certificate /etc/nginx/ssl/nginx.crt; root /var/www/html; index index.html index.htm index.nginx-debian.html; location /upload { proxy_pass http://localhost:8081/upload; 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_redirect http://localhost:8081upload https://localhost:8081/upload; } } 端口仍然在http中,但不在https中。 这是告诉我“失败的安全连接”。 你可以帮我吗? 谢谢,