nginx - Nginx + Naxsi 配置(proxy_pass)
问题描述
我正在尝试使用 Naxsi 作为代理配置 Nginx(将请求重定向到另一个域)。问题是,以这种方式,Naxsi 不起作用(如果我使用基本的 Nginx 进行操作,没有重定向,则配置可以正常工作)。你知道这是否可以做到吗?
nginx.conf
user www-data;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
include /etc/nginx/naxsi_core.rules;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name example.com;
location / {
include /etc/nginx/naxsi.rules;
proxy_set_header 'Access-Control-Allow-Origin' 'http://midominio.com';
proxy_set_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
proxy_set_header 'Access-Control-Allow-Headers' 'X-Requested-With,Accept,Content-Type, Origin';
proxy_pass http://otherexample.es;
proxy_redirect off;
proxy_buffering on;
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 origin 'http://example.com';
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
纳西规则
SecRulesEnabled;
DeniedUrl "/error.html";
## Check for all the rules
CheckRule "$SQL >= 8" BLOCK;
CheckRule "$RFI >= 8" BLOCK;
CheckRule "$TRAVERSAL >= 4" BLOCK;
CheckRule "$EVADE >= 4" BLOCK;
CheckRule "$XSS >= 8" BLOCK;
谢谢!
解决方案
推荐阅读
- sql-server - 在 SQL Server 2016 中使用 csv 文件批量加载数据转换错误
- asp.net-mvc - 删除范围上的 MVC 实体框架 VB.net 错误
- canvas - 在 Flutter 中 drawImage 或 paintImage 都不能正常工作
- sql - 有没有比这更快的方法从 T-SQL 中的 XML 节点中提取数据?
- vim - 如何在vim中删除这种模式中的东西?
- ios - 带有 cocoapods 的 Bamboo 作业给出错误:您不能以 root 身份运行 CocoaPods
- python - Matplotlib 在尝试使用 annotate() 方法时显示错误?
- arrays - Swift - 如何使用另一个数组更改字典数组中一个键的值
- excel - 根据 Y 列中的重复项删除整行并保留最后一条记录
- css - 浏览器变大时如何反转文本对齐的效果