rhubard 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_r410783890
 
 

 ##########
 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:
   I run successfully in yaml mode
   
   ```yaml
   global_rules:
     - plugins:
         serverless-pre-function:
           phase: "rewrite"
           functions:
             - "return function() if ngx.var.scheme == 'http' and ngx.var.host 
== 'xxx.com' then ngx.header['Location'] = 'https://xxx.com' .. 
ngx.var.request_uri; ngx.exit(ngx.HTTP_MOVED_PERMANENTLY); end; end"
   ```

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to