我在 symfony4 上开发了一个 api,并使用 LexikJWTAuthenticationBundle 管理我的令牌。
在 localhost 中一切正常,但在我的测试服务器(树莓派上的 ubuntu mate,apache,https)上,服务器向我发送 401 错误和无效的 JWT 令牌。
如自述文件(https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Resources/doc/index.md#generate-the-ssh-keys)中所述,我尝试添加
SetEnvIf Authorization "(. *)" HTTP_AUTHORIZATION = $ 1
配置我的虚拟主机并重新启动 apache,但这并没有改变任何东西。
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/current/rest_api/public
<Directory /var/www/html/current/rest_api/public>
# enable the .htaccess rewrites
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ServerName mydomain
SSLCertificateFile /etc/letsencrypt/live/mydomain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
</VirtualHost>
</IfModule>
谢谢你的帮助