moonming commented on issue #1430: doc: add FAQ about redirect http To https URL: https://github.com/apache/incubator-apisix/pull/1430#issuecomment-616004780 you can try the `curl` command, which is different to yaml. Thanks, Ming Wen Twitter: _WenMing JunQing Hou <notificati...@github.com> 于2020年4月19日周日 上午9:02写道: > *@rhubard* commented on this pull request. > ------------------------------ > > In FAQ.md > <https://github.com/apache/incubator-apisix/pull/1430#discussion_r410783890> > : > > > @@ -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"] > > I run successfully in yaml mode > > 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" > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/apache/incubator-apisix/pull/1430#discussion_r410783890>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AGJZBK4DXFOZXVSEDWOWW5TRNJES3ANCNFSM4MEBKHVQ> > . >
---------------------------------------------------------------- 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