moonming commented on a change in pull request #1430: doc: add FAQ about redirect http To https URL: https://github.com/apache/incubator-apisix/pull/1430#discussion_r410691181
########## File path: FAQ.md ########## @@ -107,11 +107,30 @@ curl -i http://127.0.0.1:9080/apisix/admin/routes/2 -H 'X-API-KEY: edd1c9f034335 }' ``` +## How to redirect http To https via APISIX? + +An example, redirect `http://iresty.com` to `https://iresty.com` + +here is the way: + +```shell +curl -i http://127.0.0.1:9080/apisix/admin/global_rules/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' +{ + "plugins": { + "serverless-pre-function": { + "phase": "rewrite", + "functions": ["return function() if ngx.var.scheme == 'http' and ngx.var.host == 'iresty.com' then ngx.header['Location'] = 'https://iresty.com' .. ngx.var.request_uri; ngx.exit(ngx.HTTP_MOVED_PERMANENTLY); end; end"] Review comment: This command will throw an error, have you ever run it locally? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services