首页 > 解决方案 > 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;

谢谢!

标签: nginxserverconfiguration

解决方案


推荐阅读