【发布时间】:2018-06-16 02:00:05
【问题描述】:
我有一个烧瓶应用程序在端口 8080 上运行,我想使用 Apache 作为反向代理并将 http 重定向到 https。
"/etc/apache2/sites-enabled/example.conf"
<VirtualHost *:80>
ServerAdmin support@example.com
ServerName example.com
ServerAlias www.example.com
Redirect permanent / https://example.com/
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
ErrorLog /home/helloworld/logs/error.log
CustomLog /home/helloworld/logs/access.log combined
SSLEngine on
SSLCertificateFile /home/helloworld/certs/cert.pem
SSLCertificateKeyFile /home/helloworld/certs/key.pem
ProxyPreserveHost On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
我也有一个工作的 nginx 配置来做同样的事情,但我想在生产中使用 apache。 这是nginx配置
server {
listen 80;
server_name _;
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name _;
ssl_certificate /home/helloworld/certificate/cert.pem;
ssl_certificate_key /home/helloworld/certificate/key.pem;
access_log /var/log/ex_access.log;
error_log /var/log/ex_error.log;
location / {
proxy_pass http://localhost:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
【问题讨论】:
-
测试时会发生什么(您的配置看起来不错)?
标签: apache ssl nginx reverse-proxy