首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重定向至带有hunchentoot的https

重定向至带有hunchentoot的https
EN

Stack Overflow用户
提问于 2019-05-03 04:52:27
回答 2查看 227关注 0票数 5

我设置了一个带有ssl的hunchentoot服务器。我希望将常规的http请求重定向到https。

似乎hunchentoot:define-easy-handlerhunchentoot:redirect的某种组合是可行的,但我搞不清楚。

这是我到目前为止所知道的:

代码语言:javascript
复制
(defvar *https-handler*
  (make-instance 'hunchentoot:easy-ssl-acceptor
                 :name 'ssl
                 :ssl-privatekey-file #P"/path/to/privkey.pem"
                 :ssl-certificate-file #P"/path/to/cert.pem"
                 :port 443))

(hunchentoot:start *https-handler*)
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-05-03 09:53:58

可以,您可以通过重定向到ssl版本来添加简单的http处理程序:

代码语言:javascript
复制
(defvar *http-handler*
  (make-instance 'hunchentoot:easy-acceptor
                 :name 'http
                 :port 80))

(hunchentoot:define-easy-handler (redir-to-ssl :uri (lambda (uri) t) :acceptor-names '(http)) ()
  (hunchentoot:redirect "/" :protocol :https)) ; where magic happens

然后...and也启动它:

代码语言:javascript
复制
(hunchentoot:start *http-handler*)

此版本仅重定向到索引/

票数 4
EN

Stack Overflow用户

发布于 2020-04-24 03:28:05

好的,我直接使用hunchentoot:*dispatch-table*。重定向它的方式与我发现的路径无关,除非在处理程序中使用(hunchentoot:ssl-p),否则重定向到hunchentoot:redirect。我的大多数defuned处理程序都包装在宏中以进行身份验证。所以,我只需要修改那个宏,然后M-x slime-who-macroexpands -> C-c C-k

代码语言:javascript
复制
(unless (hunchentoot:ssl-p)
  (hunchentoot:redirect (hunchentoot:request-uri*)
                       :protocol :https))
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55960088

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档