Articles of nginx

为什么在特定的服务器上有这么多的攻击?

我有几台networking服务器正在运行,其中一台在过去6个月里已经接收了6000次访问。 另一个几乎没有。 这是巧合还是我能做些什么来吸引黑客呢? 编辑:当我旋转新的服务器,有些似乎马上得到黑客的关注。 这很可能是因为IP地址被从以前的服务器重新使用,这是由于某种原因对黑客有吸引力的服务器。

如何在Ubuntu中打开443端口?

我现在有一些问题,当我们的网站下ssl和使用443端口的工作。 我发现这个网站检查您的服务器的状态。 它说443已经closures了。 Port 443 is closed on xx.xxx.xx.xxx. 过了一段时间,我尝试了一切,我不知道我做错了什么。 netstat显示了这一点: sudo netstat -anltp | grep LISTEN tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:995 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:110 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN tcp 0 […]

Ubuntu上的nginx目录列表

我search了很多,大家都说添加这些configuration文件,它会工作: location /my_directory { autoindex on; } 我打开/etc/nginx/nginx.conf文件并将其添加到http下,但服务没有启动。 添加它在http -> server并收到403 forbidden error 。 我不知道nginx。 有人可以轻易告诉我应该怎么做? 谢谢

Nginx HTTPSconfigurationredirect到错误的URL

我有Nginx作为一个上游服务器gunicorn工作。 我正在尝试将网站configuration为使用HTTPS并强制所有HTTP请求使用SSL。 这是我在/etc/nginx/conf.d/site.conf nginxconfiguration: server { listen 80; server_name _; return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name _; ssl_certificate /etc/ssl/nginx/cert_chain.crt; ssl_certificate_key /etc/ssl/nginx/private.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; add_header Strict-Transport-Security "max-age=31536000"; location / { proxy_pass http://127.0.0.1:8000/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 在我去https://example.com/page.html时候安装这个configuration文件,然后按照预期返回页面。 但是,当我使用: https://example.com/ : https://example.com/然后浏览器奇怪地redirect到: […]

Nginx的fastcgi_cache_valid vs fastcgi_cache_path的不活动

如果我configuration fastcgi_cache_path /opt/nginx levels=1:2 keys_zone=TEST:100m inactive=40m; .. fastcgi_ignore_headers Cache-Control Expires Set-Cookie; fastcgi_cache_valid 30m; 我的caching存储在上面的path多久?

Nginx将请求redirect到不存在的子目录和文件到根目录

我想将不存在的子目录的所有请求以及不存在的子目录中不存在的文件和文件redirect回根页面。 Ex. sampledomain.com/jahsdjksf/sfhsafh.php or sampledomain.com/jahsdjksf/sdfsndf/sfhsafh.php or sampledomain.com/sfhsafh.php 全部返回到sampledomain.com 目前我有以下添加到我的规则 root /home/nginx/domains/randwebsite.com/public/; index index.php; 和 try_files $uri $uri/ /index.php; 但问题是,当我尝试任何随机不存在的子目录,它加载在该url下的主页面和它的破碎,因为CSS等使用该url与不存在的子目录,但只适用于不存在的文件与完美没有子目录添加 ex. sampledomain.com/sdlfsdlfsf.php

拒绝所有的文件夹,除了一些PHP文件

我有一个脚本来设置下载主机的一些限制。 这个脚本给了我一些文件(index.php|dl.php|config.php) ,我必须把它们放在我的下载主机上。 脚本也有这些htaccess代码: Order allow,deny Deny from All <FilesMatch "^(index\.php)?$"> Allow from All </FilesMatch> <FilesMatch "^(dl\.php)?$"> Allow from All </FilesMatch> 但我的networking服务器是NGINX。 我应该把什么重写代码放在nginx.conf? 顺便说一下,我想对vip文件夹mysomain.com/vip设置限制。 我把(index.php | dl.php | config.php)`放在上面。

ssl_verify_client除了一些之外的所有path

我有一个服务器运行在一个子域configuration像这样: server { listen 80 default_server; listen [::]:80 default_server; server_name x.example.com; return 301 https://$server_name$request_uri; } server { listen 443 ssl; listen [::]:443 ssl; <ssl configuration from https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=nginx-1.6.2&openssl=1.0.1t&hsts=no&profile=modern> ssl_client_certificate /etc/ssl/certs/root-ca.crt; ssl_verify_client on; ssl_verify_depth 2; root /var/www/html; index index.html index.htm; location / { try_files $uri $uri/ =404; } } 目前,我使用自己的根CA作为客户端validation和服务器的主要证书。 我想过渡到使用Let's Encrypt证书,但这会带来一个问题,因为Let's Encryptvalidation过程将需要访问x.example.com/.well-known并且没有匹配的客户端证书。 我已经尝试添加像这样的第二个服务器块,如这里推荐,但我一直无法得到它的工作: server { listen […]

nginx php-fpm:连接上游时,权限被拒绝

安装nginx和php-fpm之后,甚至在设置所有必要的权限之后,下面的错误就不会发生: [error] 2443#0: *2 connect() to unix:/run/php-fpm/php-fpm.pid failed (111: Connection refused) while connecting to upstream 这是我所有的configuration: /etc/php-fpm.d/www.conf [www] user = nginx group = nginx listen = /run/php-fpm/php-fpm.pid listen.owner = nginx listen.group = nginx listen.mode = 0660 listen.allowed_clients = 127.0.0.1 pm = dynamic pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 35 slowlog […]

使用nginx将许多域redirect到其他域的不同位置,而不必定义许多服务器块

假设我有多个域名的变体,一个品牌在多个顶级域名中注册; 他们都需要去一个特定的域名+附加一个专门的自定义URI与原来请求的域相关。 例如,我有: 使用domain.tld domain.net domain.org domain.com 如果domain.com是所有请求都需要登陆的地方,那么附加一个额外的URI就可以了: domain.com/tld domain.com/net domain.com/org 我想出了这个工作设置: # (www.)domain.tld server { listen 80; server_name domain.tld www.domain.tld; return 301 $scheme://www.domain.com/tld$request_uri; } # (www.)domain.net server { listen 80; server_name domain.net www.domain.net; return 301 $scheme://www.domain.com/net$request_uri; } # (www.)domain.org server { listen 80; server_name domain.org www.domain.org; return 301 $scheme://www.domain.com/org$request_uri; } # (www.)domain.com server { […]