Problems with map + subfilter + proxy
Jorge Pereira
jpereiran at gmail.com
Wed Nov 7 22:47:15 UTC 2018
Folks,
1. I have tried to use the map+subfilter as the below snip.
user nginx;
worker_processes auto;
daemon off;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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" '
'(Cache $upstream_cache_status)';
access_log /dev/stdout main;
sendfile on;
keepalive_timeout 65;
gzip on;
# Due to we are listening only http, therefore be sure to always
return http://
map $request_uri $subfilter_allowed_content_type {
volatile;
default whatever/donothing;
~/artifactory/api/nuget/.* application/atom+xml;
}
proxy_cache_path /var/cache/nginx/artifactory
levels=1:2
keys_zone=artifactory_cache:50m
max_size=50g
inactive=24h
use_temp_path=off;
server {
listen 80;
server_name ~(?<repo>.+)\.artifactory.tapioca.lan;
resolver 8.8.8.8;
set $upstream https://artifactory.myaws.com/artifactory;
location /artifactory/ {
sub_filter_types $subfilter_allowed_content_type; # the
variable is filled up correctly
#sub_filter_types "application/atom+xml"; # but, when
use it hardcode. then it works fine.
sub_filter_last_modified on;
sub_filter "https://$host" http://$host"; # it works
only when use sub_filter_types with hardcore value.
sub_filter_once off;
# its been filled correctly
add_header X-Debug-subfilter-allowed-content-type
"$subfilter_allowed_content_type";
proxy_read_timeout 60s;
proxy_pass_header Server;
proxy_cookie_path ~*^/.* /;
if ( $request_uri ~ ^/artifactory/(.*)$ ) {
proxy_pass $upstream/$1;
}
proxy_pass $upstream;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Artifactory-Override-Base-Url
$http_x_forwarded_proto://$host:$server_port/artifactory;
proxy_set_header X-JFrog-Art-Api $artifactory_token;
}
}
}
2. I do the request like.
curl -s -H "Host: artifactory-proxy.mylan.fni" "
http://172.17.0.2/artifactory/api/nuget/v3/dtfni-nuget/Packages(Id='AttributeRouting.Core.Web
',Version='3.5.6')"
Conclusion: the variable it been filled up correctly, but the
sub_filter_types looks to not process. Someone has any suggestion?
ps: I am using the nginx 1.12.x
--
Jorge Pereira
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20181107/eb2d1f60/attachment.html>
More information about the nginx
mailing list