Articles of nginx

iptables阻止nginx成为node.js的反向代理

有一些麻烦,我的限制性的iptables设置。 我有nginx(端口80)设置为node.js(端口8080)前面的反向代理。 当iptables服务停止时,一切正常。 当它重新打开,我得到来自nginx的代理超时错误。 不工作的部分是“INCOMING”部分中的“HTTP(node.js)”块 ; 请参阅下面的实际configuration文件内容。 这是相当混乱的,因为我覆盖了我的系统中唯一的两个以太网“适配器”: eth0和lo 。 这个问题是否与nginx在eth0和lo上与node.js交谈的事实? 这是我的iptablesconfiguration: # Remove all existing rules iptables -F # Set default chain policies iptables -P INPUT DROP iptables -P FORWARD DROP iptables -P OUTPUT DROP ##### BEGIN: INCOMING ##### # HTTP (nginx) iptables -A INPUT -i eth0 -p tcp –dport 80 -m state –state […]

Nginx位置“〜\ .. * /。* \。php $”是做什么用的?

这个问题涉及到Drupal&nginx:一个健全的“通用”configuration? 我已经基于我发现的一些例子成功configuration了Nginx。 事情工作正常,但我无法弄清楚下面的位置指令正在做什么: location ~ \..*/.*\.php$ { return 403; } 我认为它是防止.php文件被访问,但在哪些情况下,我不明白?

如何一般删除Nginx中的域的www?

我在nginx中有一个匹配几个域的服务器configuration: server { server_name example1.com example2.com example3.com; # … } 我想将www版本redirect到相应的域名。 我知道如何做一个单一的域redirect,我会知道如何做相反的事情,但我不能在这里find一种方法。 任何想法 ? 谢谢 ! 🙂

如何从一个单一的根服务多个位置?

我有nginx服务静态文件,从uripath映射到文件夹path,如: www.tempuri.org/js <=> /var/www/plublic/js www.tempuri.org/css <=> /var/www/plublic/css www.tempuri.org/img <=> /var/www/plublic/img www.tempuri.org/foobar <=> /var/www/plublic/foobar 在我的nginx conf中,这个规则基本上都有相同的根: location /js/ { root /var/www/public/; } location /css/ { root /var/www/public/; } location /foobar/ { root /var/www/public/; } location /img/ { root /var/www/public/; } 我怎样才能为所有4条path写一条规则? location /(css|js|img|foobar)/ { root /var/www/public } ?

如何清除nginxcaching

我的nginxconfiguration在这里: http : //p.ngx.cc/0c 这个链接http://aa-tour.ru/static/system/css/style.css显示我旧的caching版本的文件,如何删除它并清除caching? 这是正确的(新)版本的文件http://aa-tour.ru/static/system/css/style.css?v=1 这只是静态文件。 我更新了它(添加了一些类contact-form , contact-form-button )…

我是否需要在我的服务器上安装SSL证书才能从443redirect到80?

我想在我的nginx web服务器中将所有HTTPS请求redirect到HTTP。 我通过了以下做法: server { listen 443; server_name my.site.com; rewrite ^(.*) http://$host$1 permanent; } 但任何时候我尝试打https://my.site.com我在我的浏览器中出现以下错误: 无法与服务器build立安全连接。 这可能是服务器的问题,或者可能需要您没有的客户端身份validation证书。 错误代码:ERR_SSL_PROTOCOL_ERROR 我检查了nginx日志,发现下列条目: T="2013-09-27T22:41:05+00:00" IP=108.166.113.99 USR=- RQ="GET / HTTP/1.1" ST=200 BB=6237 MS=0.000 REF="-" UA="python-requests/0.13.6 CPython/2.7.3 Linux/3.2.0-24-virtual" T="2013-09-27T22:41:05+00:00" IP=108.166.113.99 USR=- RQ="GET / HTTP/1.1" ST=301 BB=184 MS=0.000 REF="-" UA="python-requests/0.13.6 CPython/2.7.3 Linux/3.2.0-24-virtual" T="2013-09-27T22:41:05+00:00" IP=108.166.113.99 USR=- RQ="GET / HTTP/1.1" ST=200 BB=6237 MS=0.000 REF="-" […]

如何防止nginx调节与维护模式冲突?

我们使用HttpLimitReqModule nginx mondule进行速率限制,并发现它与我们的“ 维护模式 ”冲突,因为这两个组件都使用http状态码503 。 当激活限制(通过limit_req指令)时,nginx通常会提供一个503,但不幸的是我们的维护模式位置被使用,导致我们的Amazon S3托pipe维护页面302。 一个302节制的请求不是一个好的结果 。 我想知道其他人如何处理这个问题? 例如,我应该为我们的维护页面使用不同的状态代码,但是如果是这样,是什么? 理想情况下,对于受限制的请求,我不希望提供任何页面,只有503响应头 – 它需要尽可能轻量级,因为整个问题是阻止服务器不堪重负。 作为参考,这是我们用于“维护模式”的nginxconfiguration: server { … # Redirect processing of 503 error pages into a named location: error_page 503 @maintenance; # "Maintenance Mode" is off by default – Use a nginx variable to track state. set $maintenance off; # Switch on "Maintenance […]

nginx fastcgi重写:主脚本未知

我有以下的nginxconfiguration: location / { try_files $uri $uri/ index.html =404; if (!-e $request_filename) { rewrite ^/(.+)$ index.php?url=$1 last; } } location ~ .php$ { # protection from known vulnerability fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } ( fastcgi_params是Debian软件包的默认设置) 它适用于请求/ ,但是当请求被重写时,主文件没有find: 请求/contact应该被重写为/index.php?url=contact *104 FastCGI sent in stderr: "Primary script unknown" while reading […]

服务器的含义是什么:cloudflare-nginx?

我试图看看,特定网站的networking服务器名称是什么。 http://browserspy.dk/webserver.php 当我search时,我得到了答复 Server: cloudflare-nginx 我知道nginx和云 – 耀斑,但我从来没有听说过一个名为cloudflare-nginx的networking服务器。 通常我会得到“nginx”作为网页服务器,如果网站是由“nginx” 有人可以解释这个服务器:cloudflare-nginx的意思是?

让我们encryptionNginx无法识别的证书

我使用本指南成功创build了一些LE SSL证书。 但是,当我更新我的nginxconfiguration使用证书和redirect所有端口80stream量到443. http成功redirect到https,该网站不加载。 浏览器检测到我有一个有效的证书,但说我没有安全的连接。 这是我在/var/log/nginx/error.log : 2016/03/08 00:11:49 [error] 7301#0: *14 no "ssl_certificate" is defined in server listening on SSL port while SSL handshaking, client: 55.555.55.555, server: 0.0.0.0:443 错误说我没有定义SSL证书,尽pipe我这样做。 这是我的configuration: server { listen 443 ssl; server_name cooldomain.pizza www.cooldomain.pizza ssl_certificate /etc/letsencrypt/live/cooldomain.pizza/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/cooldomain.pizza/privkey.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; root /home/ubuntu/www/cooldomain-pizza; index index.php […]