0

I have this long URL with

http://shortk8s.com/api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/#!/workload?namespace=default

I'd like to http://shortk8s.com to go directly to the full URL while appending the query strings Ex. http://shortk8s.com?namespace=default.

So basically this part of the URL I'd like to be excluded from but somehow rewritten in NGINX.

api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/#!/workload

My initial attempt is as follows:

server {
    listen       80;
    server_name  shortk8s.com;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_cache off;

    location / {
        rewrite .* api/v1/namespaces/kube-system/services/http:kubernetes-dashboard:/proxy/#!/workload/$1  break;
        proxy_pass http://127.0.0.1:8001;
    }
}

It failed, anything suggestions?

Proximo
  • 101
  • 2
  • Sp, what exactly happened when you tried to use the rule? Curl output is needed here. – Tero Kilkanen Jul 12 '18 at 20:38
  • What failed? What's your browser output? Oh, and probably, quote your `rewrite` target, because there's a `#` symbol there. `#` is used in nginx configuration to denote a line comment. – mforsetti Jul 13 '18 at 07:54

0 Answers0