Reputation: 51921
I have an existing apache server with https
handling traffic for https://www.example.com
.
How can I config rails (and apache) to handle https
requests from another port, e.g. https://www.example.com:6000/api/v1/datafeed/
?
Upvotes: 0
Views: 102
Reputation: 38645
You can make use of the Apache proxy with balancer module. Here is how I configured rails behind Apache 2.4 with NamedVirtualHost:
Enable the following modules in 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
And something like following for your VirtualHost configuration
Listen 127.0.0.1:6000 https
<VirtualHost *:6000>
ServerAdmin [email protected]
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>
Upvotes: 1