我正在尝试在Ubuntu 16.04上的Apache中执行代理传递到在PM2中运行的nodejs服务。
我最初尝试将该服务用作在端口80上运行的普通http服务,并且工作得很好。
然后我想将它部署到生产中,因此显然需要有SSL证书。所以我在第一个VirtualHost中添加了重定向到安全服务,我将SSL内容添加到原始配置中,以使其通过当前证书在端口443上运行。
目前我有一个通配符证书,可以使用domain.com下的所有内容
<VirtualHost *:80>
ServerName my.domain.com
Redirect permanent / https://my.domain.com/servicename
</VirtualHost>
<VirtualHost *:443>
ServerName my.domain.com
DocumentRoot /var/www/servicename
SSLEngine on
SSLCertificateFile /etc/ssl/certs/my.crt
SSLCertificateKeyFile /etc/ssl/certs/my.key
# I don't actually have a ca certificate so I tried adding the my.crt again with no luck. I also don't have any .pem files either
#SSLCACertificateFile /etc/ssl/certs/my.crt
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy *>
Require all granted
</Proxy>
<Location /servicename>
ProxyPass http://127.0.0.1:8080
ProxyPassReverse http://127.0.0.1:8080
</Location>
</VirtualHost>
但是,当我保存此配置并执行sudo systemctl restart apache2时,它告诉我apache无法启动
Job for apache2.service failed because the control process exited with error code. See "systemctl status apache2.service" and "journalctl -xe" for details.
然后我运行systemctl status apache2.service,我得到以下内容:
apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
apache2-systemd.conf
Active: failed (Result: exit-code) since Mon 2017-11-06 12:41:54 CST; 40s ago
Docs: man:systemd-sysv-generator(8)
Process: 10361 ExecStop=/etc/init.d/apache2 stop (code=exited,status=0/SUCCESS)
Process: 9310 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
Process: 10476 ExecStart=/etc/init.d/apache2 start (code=exited, status=1/FAILURE)
我在配置中做错了什么?
答案 0 :(得分:0)
在@Kryten的建议下使用apachectl configtest
我能够弄清楚我没有安装ssl所以解决方案是sudo a2enmod ssl
和apache开始了!