与 Apache 一起使用
您可以在 Apache “代理“后面运行 Martin,这样您就可以使用 HTTPs。以下是使用 Apache 运行 Martin 的配置文件示例。
首先,您必须设置一个在端口 443 上工作的虚拟主机。
启用必要的模块
确保所需的模块已启用:
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod headers
sudo a2enmod rewrite
修改您的 VHOST 配置
打开您正在使用的域名的 VHOST 配置文件,mydomain.tld:
sudo nano /etc/apache2/sites-available/mydomain.tld.conf
更新配置
<VirtualHost *:443>
ServerName mydomain.tld
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mydomain
ProxyPreserveHost On
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/tiles/(.*)$
RewriteRule ^/tiles/(.*)$ http://localhost:3000/tiles/$1 [P,L]
<IfModule mod_headers.c>
RequestHeader set X-Forwarded-Proto "https"
</IfModule>
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</VirtualHost>
检查配置:验证 Apache 配置的语法错误
sudo apache2ctl configtest
重启 Apache:如果配置正确,重启 Apache 以应用更改
sudo systemctl restart apache2