JoniJnm commented on issue #1903:
URL:
https://github.com/apache/apisix-ingress-controller/issues/1903#issuecomment-1649556057
It works, ty
```yaml
plugins:
- name: serverless-pre-function
enable: true
config:
phase: rewrite
functions:
- |
return function()
if ngx.var.scheme == "http" then
ngx.status = ngx.HTTP_UPGRADE_REQUIRED
ngx.header["content-type"] = "application/json"
ngx.say('{"error": "Use HTTPs"}')
ngx.exit(ngx.HTTP_UPGRADE_REQUIRED)
end
end
```
I tried to use
[request-validation](https://apisix.apache.org/docs/apisix/plugins/request-validation/)
using header: schema=https but seems like the header doesn't exists (tried
with http_schema also)
I tried also ApisixRoute with `http[].match.exprs` but in the list of scopes
(Header, Query, Cookie, Path) there isn't a "[special ngx
context](http://nginx.org/en/docs/varindex.html)" to filter by schema as in the
example code in your link:
```shell
curl -i http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY:
edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/hello",
"host": "foo.com",
"vars": [
[
"scheme",
"==",
"http"
]
],
"plugins": {
"redirect": {
"uri": "https://$host$request_uri",
"ret_code": 301
}
}
}'
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]