gpt4 book ai didi

ruby-on-rails - https 用于同一apache服务器中非标准端口上的rails应用程序?

转载 作者:行者123 更新时间:2023-12-04 19:38:36 27 4
gpt4 key购买 nike

我有一个现有的 apache 服务器,带有 https处理 https://www.example.com 的流量.

如何配置 rails(和 apache)来处理 https来自另一个端口的请求,例如https://www.example.com:6000/api/v1/datafeed/ ?

最佳答案

您可以使用带有平衡器模块的 Apache 代理。以下是我使用 NamedVirtualHost 在 Apache 2.4 后面配置 Rails 的方法:

httpd.conf 中启用以下模块:

LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so​
LoadModule proxy_http_module modules/mod_proxy_http.so​
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so​

以及类似以下内容的 VirtualHost 配置
Listen 127.0.0.1:6000 https

<VirtualHost *:6000>
ServerAdmin webmaster@example.com
ServerName www.example.com

DocumentRoot "rails_root/public"
<Directory "rails_root/public"
Require all granted
Options -MultiViews
</Directory>

ProxyPass / balancer://myapp_cluster/
ProxyPassReverse / balancer://myapp_cluster/
ProxyPreserveHost On
ProxyVia On

<Proxy balancer://myapp_cluster>
# Note the port here, this should be the port where your rails app is running.
BalancerMember http://localhost:3000
</Proxy>

SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
SSLCertificateFile "/etc/httpd/conf/ssl/certificate_file.crt"
SSLCertificateKeyFile "/etc/httpd/conf/ssl/certificate_key.key"

ErrorLog "/var/log/httpd/error.log"
CustomLog "/var/log/httpd/access.log" combined
</VirtualHost>

关于ruby-on-rails - https 用于同一apache服务器中非标准端口上的rails应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18049367/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com