Прокси-переход в подкаталог URL-адреса - PullRequest
0 голосов
/ 02 августа 2020

Я запускаю сервер omt в Docker в Linux сервере (работает nginx). Я могу получить к нему доступ, используя ip: port

Я пытаюсь передать его через прокси в мой подкаталог apache, но он разрешается в основной каталог (/)

Пример: Когда я попробуйте проксировать 172.16.xx: 8888 на https://example.com/test/openmaptiles/, он пытается искать сценарии в https://example.com/

Как мне сделать openmaptiles каталогом по умолчанию?

nginx config:

# NOTE: This file is partially modified at runtime by the wizard!
server {
  listen 80;
  error_page 502 =200 @loading;
  location @loading {
    internal;
    root /usr/local/src;
    try_files /loading.html /loading.html;
  }
  location /services {
    rewrite ^([^\?#]*/)([^\?#\./]+)([\?#].*)?$ $1$2/$3 permanent;
    fastcgi_param QUERY_STRING       $query_string;
    fastcgi_param REQUEST_METHOD     $request_method;
    fastcgi_param CONTENT_TYPE       $content_type;
    fastcgi_param CONTENT_LENGTH     $content_length;
    fastcgi_param SCRIPT_NAME        $fastcgi_script_name;
    fastcgi_param REQUEST_URI        $request_uri;
    fastcgi_param DOCUMENT_URI       $document_uri;
    fastcgi_param DOCUMENT_ROOT      $document_root;
    fastcgi_param SERVER_PROTOCOL    $server_protocol;
    fastcgi_param REQUEST_SCHEME     $scheme;
    fastcgi_param HTTPS              $https if_not_empty;
    fastcgi_param GATEWAY_INTERFACE  CGI/1.1;
    fastcgi_param SERVER_SOFTWARE    nginx/$nginx_version;
    fastcgi_param REMOTE_ADDR        $remote_addr;
    fastcgi_param REMOTE_PORT        $remote_port;
    fastcgi_param SERVER_ADDR        $server_addr;
    fastcgi_param SERVER_PORT        $server_port;
    fastcgi_param SERVER_NAME        $http_host;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_split_path_info ^(/services)(.*)$;
    fastcgi_pass localhost:8081;
    add_header Access-Control-Allow-Origin "https://iitg.ac.in/cseweb/osint/map-server/";
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
    add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
    add_header 'Access-Control-Max-Age' 1728000;
  }
  location / {
    proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto  $http_x_forwarded_proto;
    proxy_set_header Host               $http_host;
    proxy_pass http://localhost:8080;
  }
  rewrite ^/styles/([^/]+)//(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20)/([0-9]+)/([0-9]+).(png|jpg|webp)$ /services/gmaps/$1@1x/$2/$3/$4.$5 last;
  rewrite ^/styles/([^/]+)//(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20)/([0-9]+)/([0-9]+)@2x.(png|jpg|webp)$ /services/gmaps/$1-2@2x/$2/$3/$4.$5 last;
}

apache proxypass:

ProxyPass /osint/map-server/ http://172.16.117.202:8888/                       
ProxyPassReverse /osint/map-server/ http://172.16.117.202:8888/ 

результат: введите описание изображения здесь

...