# Chrome cache large source map making them out of date. # 解决 Chrome 缓存大型 source map 文件导致它们过时的问题 location ~ \.js\.map$ { add_header Cache-Control "no-cache; no-store"; # 不缓存不存储 proxy_pass_header Authorization; # 是将客户端请求中的 Authorization 头传递给上游服务器,Authorization nginx 是默认会过滤掉的,所以需要显式的设置传输到上游服务器 proxy_pass http://$gohost$gohostExt; # 传输给上游服务 }
# turn on auth check by default # 默认设置 set$panAuthCheck'on';
# unauth 的时候不检查认证 if ($uri ~ ^\/unauth\/.+$) { set$panAuthCheck'off'; }
if ($uri = /php/logout.php) { set$panAuthCheck'off'; }
# new login rules # 匹配登录的静态文件 images js location ~ ^/login/(images|js)/ { # 重写: /login/(images|js)/(.*)$ => /$1/login/$2 # $1 (images|js), $2 (.*) rewrite /login/(images|js)/(.*)$ /$1/login/$2break; # 静态资源根目录 root /var/appweb/htdocs; # It is directly retrieving static files, we can not do proxy_hide_header, instead should just use add_header add_header Last-Modified ""; add_header Cache-Control "max-age=86400"; }
location ~ ^/login/(css|fonts)/ { root /var/appweb/htdocs/styles/; # It is directly retrieving static files, we can not do proxy_hide_header, instead should just use add_header add_header Last-Modified ""; add_header Cache-Control "max-age=86400"; }
# block unauthorized `/upload` access # this prevents hacker dumping files to the system to fill up disk space. # 不允许 upload 的访问 location /upload { return 403; }
# plugins not going through proxy and backend location ~ ^/plugins/([^\/]*)/ui/(js|styles|generated|VMSeries_Help|help)/ { rewrite /plugins/([^\/]*)/ui/(js|styles|generated|VMSeries_Help|help)/(.*)$ /installed/$1/ui/$2/$3 break; # It is directly retrieving static files, we can not do proxy_hide_header, instead should just use add_header add_header Last-Modified ""; add_header Cache-Control "max-age=86400"; root /opt/plugins; }
# look for upload if ($content_type ~* "multipart/form-data") { error_page 402 =200 @upload_api; return 402; }
if ($devonly = 1) { set$gohostExt$server_port; }
include conf/proxy_default.conf; proxy_pass http://$gohost$gohostExt; # Remove Last-modified from proxy header proxy_hide_header Last-Modified; }
location /api { # do not know why "last" is needed and "break" does not work for api browser rewrite ^(/api)(\/?)$ $1/index.php last; rewrite ^(/api)(\/.*)$ $1/index.php$2 last; }
# `wget` POST does not work. # If not regression, this will be removed # if ($arg_client = 'wget') { # error_page 402 =200 @api_wget_file; return 402; # set $isWgetLoad "w"; # } # if ($arg_file-name) { # set $isWgetLoad "${isWgetLoad}f"; # }
# look for upload if ($content_type ~* "multipart/form-data") { error_page 402 =200 @upload_api; return 402; }
include conf/proxy_default.conf; proxy_pass http://$gohost$gohostExt; # Remove Last-modified from proxy header proxy_hide_header Last-Modified; }
# route `/restapi-doc` to `/restapi-doc/` as `DirectorySlash off` in httpd location = /restapi-doc { if ($args) { return 302 /restapi-doc/?$args; } return 302 /restapi-doc/; }
# It is added to prevent restapi-doc page using default config location /restapi-doc/ { include conf/proxy_default.conf; proxy_pass http://$gohost$gohostExt; }
location /error_page/ { root /var/appweb/htdocs; # It is directly retrieving static files, we can not do proxy_hide_header, instead should just use add_header add_header Last-Modified ""; add_header Cache-Control "max-age=86400"; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; internal; # 只有通过内部重定向(如 rewrite 或 error_page)才能访问这个路径,而不能直接从外部(客户端)访问。 }
if ( $_SERVER['HTTP_X_PAN_AUTHCHECK'] != 'off' && $_SERVER['PHP_SELF'] !== '/CA/ocsp' && $_SERVER['PHP_SELF'] !== '/php/login.php' && stristr($_SERVER['REMOTE_HOST'], '127.0.0.1') === false ) { $_SERVER['PAN_SESSION_READONLY'] = true; $ws = WebSession::getInstance($ioc); $ws->start(); $ws->close(); // these are horrible hacks. // This whole code should be removed and only make available to a few pages: main, debug, etc. if ( !Str::startsWith($_SERVER['PHP_SELF'], '/php-packages/panorama_webui/php/api/index.php') && !Str::startsWith($_SERVER['PHP_SELF'], '/php-packages/firewall_webui/php/api/index.php') ) { if (Backend::quickSessionExpiredCheck()) { if (isset($_SERVER['QUERY_STRING'])) { Util::login($_SERVER['QUERY_STRING']); } else { Util::login(); } exit(1); } } }