`
bnmnba
  • 浏览: 287883 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

Weblogic禁用TRACE和不安全的HTTP method方法,自定义501 403 404 500错误页面

 
阅读更多

暂时未找到weblogic本身开启TRACE,以便用过滤器拦截不需要的HTTP方法。

所以使用nginx反向代理实现。

Nginx关键配置:

   server {
#部分省略
        location /webroot{
#部分省略

            #开启代理错误拦截            
            proxy_intercept_errors on; 
            #设置只接受HTTP的GET和POST方法。
            limit_except GET POST {
                deny  all;
            }
        }
        #开启错误拦截
        fastcgi_intercept_errors on;
        #自定义错误页面
        error_page   500 502 503 504 501 404 405 400 403  /error.html;
        location = /error.html {
            root   html;
            allow all;
        }
    }

 

 

放置$ngnixHome/html/error.html:

<!DOCTYPE html>
<html>
<head>
<title>Error</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>error!</h1>
</body>
</html>

 

 

Nginx配置文件详情:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;

 upstream mysvr {
        server 127.0.0.1:7002;
        #server 20.59.65.7:8080;
        #server 20.59.65.9:8080;
        #server 20.59.65.10:8080;
	ip_hash;
    }
    server {
        listen       1888;
        server_name  127.0.0.1;
        charset utf-8;
        client_max_body_size 100M;

        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location /webroot{
            proxy_set_header Host $host:$server_port;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass   http://mysvr;
            proxy_connect_timeout 1;
            proxy_send_timeout 120;
            proxy_read_timeout 120;
            limit_except GET POST {
                deny  all;
            }
        }
        fastcgi_intercept_errors on;
        error_page   500 502 503 504 501 404 405 400 403  /error.html;
        
        location = /error.html {
            root   html;
            allow all;
        }
        # redirect server error pages to the static page /50x.html
        #
        #location = /50x.html {
        #    root   html;
        #}

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

 

测试使用的Nginx版本是nginx-1.14.0 Windows版。

Nginx下载地址:http://nginx.org/en/download.html

各个发行版Linux离线安装包位于:http://nginx.org/packages/

 

 常用Nginx命令:

  nginx -s start
  nginx -s stop
  nginx -s reload


参考:https://stackoverflow.com/questions/8505678/nginx-error-pages-not-working
https://blog.csdn.net/xuyaqun/article/details/5988003

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics