【发布时间】:2019-08-27 05:46:23
【问题描述】:
在调试和调整时,我暂时将我的网站限制为我的单个 IP。很遗憾。 nginx 允许我的 IP 然后拒绝所有似乎都没有做这项工作!
我知道连接了“被拒绝”的 IP,因为以下会返回许多列表:
netstat -anp | grep -E ":80|:443" | grep ESTABLISHED
我最小的 nginx.conf:
server {
server_name myserver.com;
root /var/www/myserver;
index index.php;
include global/restrictions.conf;
allow 107.77.323.112; # allowed IP address
deny all;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php7.2-fpm.sock;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
listen 443 ssl;
ssl_certificate /home/admin/myserver_com.chained.crt;
ssl_certificate_key /home/admin/-myserver.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
}
【问题讨论】:
-
我将允许和拒绝语句移到 http 块,但没有帮助。
-
我想必须与 nginx 建立连接才能返回 403。在我看来,我看到的连接比返回快速 403 结果更持久。
标签: nginx