我正在尝试部署我的Rails应用程序。我经历了很多错误,但目前停留在ERR_TOO_MANY_REDIRECTS
。
我的服务器是基于Apache的。我已经在Apache后面设置了Nginx(带乘客),并且正在使用反向代理将特定子域上的流量从Apache转发到Nginx。之后,我会将配置文件作为代码段附加。
这是我的Apache conf文件:
# /etc/apache2/sites-enabled/hangzz.benhickson.com.conf
<VirtualHost *:80>
ServerName hangzz.benhickson.com
ServerAdmin ben@benhickson.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
<Location />
Order allow,deny
Allow from all
</Location>
RewriteEngine on
RewriteCond %{SERVER_NAME} =hangzz.benhickson.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# /etc/apache2/sites-enabled/hangzz.benhickson.com-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName hangzz.benhickson.com
ServerAdmin ben@benhickson.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
<Location />
Order allow,deny
Allow from all
</Location>
SSLCertificateFile /etc/letsencrypt/live/hangzz.benhickson.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/hangzz.benhickson.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
还有我的NGINX配置:
# /etc/nginx/sites-enabled/hangzz
server {
listen 8080 ssl;
listen [::]:8080 ssl;
server_name hangzz.benhickson.com;
root /home/ben/hangzz/current/public;
passenger_enabled on;
passenger_app_env production;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto https;
location /cable {
passenger_app_group_name hangzz_websocket;
passenger_force_max_concurrent_requests_per_process 0;
}
# Allow uploads up to 100MB in size
client_max_body_size 100m;
location ~ ^/(assets|packs) {
expires max;
gzip_static on;
}
}
我可以在不使用SSL的情况下很好地部署我的应用,但是我们都知道这是个坏主意。
在我config.force_ssl = true
错误中设置了 /config/environments/production.rb
。
我了解我在某处处于某种重定向循环中,请提供帮助!