我设置了一个带有ssl的hunchentoot服务器。我希望将常规的http请求重定向到https。
似乎hunchentoot:define-easy-handler和hunchentoot:redirect的某种组合是可行的,但我搞不清楚。
这是我到目前为止所知道的:
(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*)发布于 2019-05-03 09:53:58
可以,您可以通过重定向到ssl版本来添加简单的http处理程序:
(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也启动它:
(hunchentoot:start *http-handler*)此版本仅重定向到索引/。
发布于 2020-04-24 03:28:05
好的,我直接使用hunchentoot:*dispatch-table*。重定向它的方式与我发现的路径无关,除非在处理程序中使用(hunchentoot:ssl-p),否则重定向到hunchentoot:redirect。我的大多数defuned处理程序都包装在宏中以进行身份验证。所以,我只需要修改那个宏,然后M-x slime-who-macroexpands -> C-c C-k。
(unless (hunchentoot:ssl-p)
(hunchentoot:redirect (hunchentoot:request-uri*)
:protocol :https))https://stackoverflow.com/questions/55960088
复制相似问题