Problems with map + subfilter + proxy

Jorge Pereira jpereiran at
Wed Nov 7 22:47:15 UTC 2018


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 {
    default                         whatever/donothing;
    ~/artifactory/api/nuget/.*      application/atom+xml;

  proxy_cache_path /var/cache/nginx/artifactory

  server {
    listen 80;
    server_name ~(?<repo>.+)\.artifactory.tapioca.lan;


    set $upstream;

    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

      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
      proxy_set_header    X-JFrog-Art-Api   $artifactory_token;

2. I do the request like.

curl -s -H "Host: artifactory-proxy.mylan.fni" "'AttributeRouting.Core.Web

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: <>

More information about the nginx mailing list