Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i tried to https to http reverse proxy. then fail #420

Open
uk-taniyama opened this issue Sep 19, 2021 · 3 comments
Open

i tried to https to http reverse proxy. then fail #420

uk-taniyama opened this issue Sep 19, 2021 · 3 comments

Comments

@uk-taniyama
Copy link

export-url : https://export.example.com/api/v1
go-api-url : http://app.example.com/api/v1

Server-URL:
NG : https://export.example.com/api/v1
NG : /api/v1 -> fail

So, i change to swagger data.
Send to client

	swagger.Servers = openapi3.Servers{
		{URL: "/api/v1"},
	}

send to validate middleware.

        // remove servers and  rewrite from relative-path to absolute-path
	swagger.Servers = openapi3.Servers{}
	paths := openapi3.Paths{}
	for k, v := range swagger.Paths {
		paths[path.Join(basePath, k)] = v
	}
	swagger.Paths = paths
@uk-taniyama
Copy link
Author

I don't think middleware needs any Server information.
Because it is not possible to know the address accessed by the user under the proxy environment.

@fenollp
Copy link
Collaborator

fenollp commented Oct 2, 2021

What is the issue?
Where is your issue-reproducing code?
What have you tried?

@uk-taniyama
Copy link
Author

frontend server:https://example.com/
-> reverse-proxy ->
backend server:http://goserver/

So. OpenAPI spec's server.url is "https://example.com/v1/".

But goserver cannot match /v1/pets.

goserver_1  | 2021/10/02 13:50:46 routeRegexp:path /v1/pets ^/v1/pets$
goserver_1  | 2021/10/02 13:50:46 methodMatcher
goserver_1  | 2021/10/02 13:50:46 schemeMatcher
goserver_1  | 2021/10/02 13:50:46 1 
goserver_1  | 2021/10/02 13:50:46 2 [https] http false
goserver_1  | 2021/10/02 13:50:46 DONT MATCH [https] &{<nil> <nil> map[] <nil>}
goserver_1  | 2021/10/02 13:50:46 routeRegexp:path /v1/pets ^/v1/pets/(?P<v0>[^/]+)$
goserver_1  | 2021/10/02 13:50:46 DONT MATCH &{/v1/pets/{petId} 0 {false true} 0xc00010fae0 /v1/pets/%s [petId] [0xc00010f9a0] false} &{<nil> <nil> map[] <nil>}

sample project is follows:
https://github.com/uk-taniyama/kin-openapi-issue420

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants