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

How to bind multi-domain with different router, ssl, and proxies? #1135

Open
UnionMexicanaDelNorte opened this Issue Nov 13, 2018 · 0 comments

Comments

Projects
None yet
1 participant
@UnionMexicanaDelNorte

UnionMexicanaDelNorte commented Nov 13, 2018

Hi guys.

First of all, congratulations for the web framework, is great.

I have 4 domains, and I need a different router for each domain.

I need it to work with ssl, and port 80 redirect to the secure address. I based on: #482 for the multidomain, and in: https://github.com/kataras/iris/blob/master/_examples/http-listening/listen-tls/main.go#L22 to redirect port 80, however, multidomain works well with ssl, but port 80 always redirects to the same domain, that is:

https://one.org works fine
https://two.org works fine
https://three.org works fine
https://four.org works fine

http://one.org works fine
http://two.org redirect to one.org, must redirect to two.org
http://three.org redirect to one.org, must redirect to three.org
http://four.org redirect to one.org, must redirect to four.org

here my code:

defSubdomain2:= app.Party("two.")
{
   defSubdomain2.Get("/", func(ctx iris.Context) {
		ctx.HTML("<h1>Hello two.org</h1>")
	})
}

defSubdomain3:= app.Party("three.")
{
   defSubdomain3.Get("/", func(ctx iris.Context) {
		ctx.HTML("<h1>Hello three.org</h1>")
	})
}

defSubdomain4:= app.Party("four.")
{
   defSubdomain4.Get("/", func(ctx iris.Context) {
		ctx.HTML("<h1>Hello four.org</h1>")
	})
}

target, _ := url.Parse("https://one.org:443")
go host.NewProxy("one:80", target).ListenAndServe()


targetTWO, _ := url.Parse("https://two.org:443")
targetTHREE, _ := url.Parse("https://three.org:443")
targetFOUR, _ := url.Parse("https://four.org:443")
go host.NewProxy("two.org:80", targetTWO).ListenAndServe()
go host.NewProxy("three.org:80", targetTHREE).ListenAndServe()
go host.NewProxy("four.org:80", targetFOUR).ListenAndServe()

appConf := iris.Configuration{
	DisablePathCorrection: true,
}

app.Run(iris.TLS(":443", "somefile.pem", "otherfile.pem"), iris.WithConfiguration(appConf))

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment