nginx-adapter icon indicating copy to clipboard operation
nginx-adapter copied to clipboard

support nginx-adapter rewrite regexp

Open Chise1 opened this issue 6 months ago • 3 comments

I'm trying to add some functions to the nginx-adapter.I found that the rewrite of nginx-adapter seems not to support regular expressions In nginx,config like :

  location ^~ /api {
    rewrite ^/api(/.*)$ $1 break;
    proxy_pass http://127.0.0.1:8000;
  }

It should be write :


	rewriteHandler := Rewrite{
		PathRegexp: []*regexReplacer{
			{
				Find:    "^/api(/.*)$",
				Replace: "$1",
			},
		},
	}

But regexReplacer can not be use in nginx-adapter. What should I do?

Chise1 avatar May 08 '25 08:05 Chise1

Thank you for working on enhancing the adapter! Supporting replacements was tricky, and I have unfinished work that was never pushed. I believe you can encode them as JSON, then unmarshal them into the Rewrite struct. Does that work?

mohammed90 avatar May 08 '25 10:05 mohammed90

I can try to complete part of the work of nginx-adapter.

Chise1 avatar May 08 '25 10:05 Chise1

That would be cool! Thank you!

mholt avatar May 08 '25 13:05 mholt