我有一个在Amazon Linux服务器上运行的Spring Boot应用程序。 我使用Apache HTTP服务器作为这个应用程序的代理服务器。 最近,我安装了Let's Encrypt SSL证书,并在Apache上添加了一个虚拟主机条目。 但是,我无法正确使用Spring Boot。 没有SSL版本似乎工作正常。
我观察到的是,当用户调用https版本的时候,请求来到了Spring Boot应用程序,但是用户收到来自Apache的HTTP 404错误。 例如,这工作正常: http : //example.com/oauth/token但这不起作用,并返回404: https : //example.com/oauth/token
我发布了下面的configuration文件,我错过了什么?
vhosts.conf
<VirtualHost *:443> ServerName example.com ServerAlias www.example.com ServerAdmin [email protected] DocumentRoot /var/www/example.com/public_html ErrorLog /var/www/example.com/logs/error.log CustomLog /var/www/example.com/logs/access.log combined RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d RewriteRule ^ - [L] RewriteRule ^(/api/v1) - [L] RewriteRule ^(/oauth/token) - [L] RewriteRule ^ /index.html [L] SSLEngine on SSLCertificateFile /var/www/example.com/cert/cert.pem SSLCertificateKeyFile /var/www/example.com/cert/privkey.pem ProxyPreserveHost on RequestHeader set X-Forwarded-Proto https RequestHeader set X-Forwarded-Port 443 ProxyPass /api/v1 http://127.0.0.1:8080/api/v1 ProxyPassReverse /api/v1 http://127.0.0.1:8080/api/v1 ProxyPass /oauth/token http://127.0.0.1:8080/oauth/token ProxyPassReverse /oauth/token http://127.0.0.1:8080/oauth/token </VirtualHost> <VirtualHost *:80> ServerName example.com ServerAlias www.example.com ServerAdmin [email protected] DocumentRoot /var/www/example.com/public_html ErrorLog /var/www/example.com/logs/error.log CustomLog /var/www/example.com/logs/access.log combined RewriteEngine On RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR] RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d RewriteRule ^ - [L] RewriteRule ^(/api/v1) - [L] RewriteRule ^(/oauth/token) - [L] RewriteRule ^ /index.html [L] ProxyPreserveHost on ProxyPass /api/v1 http://127.0.0.1:8080/api/v1 ProxyPassReverse /api/v1 http://127.0.0.1:8080/api/v1 ProxyPass /oauth/token http://127.0.0.1:8080/oauth/token ProxyPassReverse /oauth/token http://127.0.0.1:8080/oauth/token </VirtualHost>
application.properties
server.context-path=/api/v1 server.address=127.0.0.1 server.port=8080 server.use-forward-headers=true server.tomcat.remote_ip_header=x-forwarded-for server.tomcat.protocol_header=x-forwarded-proto