距离上次更新已经三年了;这是我在 2021 年在 macOS 上运行它的方法(作为 mario 答案的扩展):
# Install stunnel
brew install stunnel
# Find the configuration directory
cd /usr/local/etc/stunnel
# Copy the sample conf file to actual conf file
cp stunnel.conf-sample stunnel.conf
# Edit conf
vim stunnel.conf
修改stunnel.conf
为如下所示:(其他选项都可以删除)
; **************************************************************************
; * Global options *
; **************************************************************************
; Debugging stuff (may be useful for troubleshooting)
; Enable foreground = yes to make stunnel work with Homebrew services
foreground = yes
debug = info
output = /usr/local/var/log/stunnel.log
; **************************************************************************
; * Service definitions (remove all services for inetd mode) *
; **************************************************************************
; ***************************************** Example TLS server mode services
; TLS front-end to a web server
[https]
accept = 443
connect = 8000
cert = /usr/local/etc/stunnel/stunnel.pem
; "TIMEOUTclose = 0" is a workaround for a design flaw in Microsoft SChannel
; Microsoft implementations do not use TLS close-notify alert and thus they
; are vulnerable to truncation attacks
;TIMEOUTclose = 0
这在端口 443 接受 HTTPS / SSL 并连接到在端口 8000 运行的本地网络服务器,使用 stunnel 的默认伪造证书在/usr/local/etc/stunnel/stunnel.pem
. 日志级别 isinfo
并且日志输出写入/usr/local/var/log/stunnel.log
.
启动通道:
brew services start stunnel # Different for Linux
启动网络服务器:
php -S localhost:8000
现在您可以访问https://localhost:443
访问您的网络服务器:screenshot
应该有一个证书错误,您必须单击浏览器警告,但这会让您到达可以使用 HTTPS 请求访问您的本地主机进行开发的地步。