A question about redirect to https with 'lb + apisix' #6928
Replies: 2 comments 9 replies
-
You can have APISIX listen to ports 80 and 443 Then create two routes, where the vars configuration is curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/hello",
"host": "foo.com",
"vars": [
[
"server_port",
"==",
80
]
]
}' curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/hello",
"host": "foo.com",
"vars": [
[
"server_port",
"==",
443
]
]
}' The server_port variable is used to determine which listening port the request is coming from, then configure redirect or other plugins on both routes to perform different actions. |
Beta Was this translation helpful? Give feedback.
-
I can't solve your problem, it looks like you are getting the correct response from nginx to APISIX, then the problem may be in the SLB. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there any way to redirect from http to https on apisix which behind a lb meanwhile use http to proxy between lb and apisix?
We want to use apisix to replace nginx. Our nginx conf is about below..
Our ssl certs are on lb. lb's 80 port proxy to nginx 80 port and 443 port proxy to nginx 443 port.
We just want to achieve the following conditions:
`server{
listen 80;
server_name www.test.com;
rewrite ^(.*)$ https://$host$1 permanent;
}
server {
listen 443 ;
server_name www.test.com;
}
`
I tried to complete this on apisix but I found that a different of apisix is that mutiple http port can't handle different configs like behand. So is there any to accomplish the goal?
Beta Was this translation helpful? Give feedback.
All reactions