apache/SOLR: access solr server by https:// domain-name

假装没事ソ 提交于 2019-12-24 20:47:43

问题


I have been using a solr search on a http IP like

http://xxx.xxx.xxx.xxx:8983/solr/#/

but now I need, for security reasons, to have a domain name + https like

https://example.com:8983/solr/#/

or (?)

https://example.com/solr/#/

either way I have no clue how to config my apache conf vhost files...

any idea?

PS. I already enabled the https for my domain https://example.com/


回答1:


You can make solr listen only to the localhost and install Apache or Nginx as reverse proxy that listens on your public IP on port 443 for HTTPS and forwards the requests to localhost on port 8983.

With NginX you can use something like this in your Virtualhost file:

server {
 listen 443 ssl http2;
 listen [::]:443 ssl http2;

 server_name example.com;

 location / {
  try_files $uri @proxy;
 }

 location @proxy {
  include cors_support;
  proxy_set_header Host $http_host;
  proxy_set_header X-Forwarded-Host $http_host;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-Forwarded-Proto https;
  proxy_set_header HTTPS "on";
  proxy_pass_header Server;
  proxy_pass http://127.0.0.1:8983;
  proxy_buffering off;
  proxy_redirect off;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  tcp_nodelay on;
 }

 access_log /var/log/nginx/access-example.log;
 error_log /var/log/nginx/error-example.log;

 include snippets/ssl-params.conf;
 include snippets/ssl-example.com.conf;
}

For Apache with module proxy and proxy_http enabled:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin support@example.com
    ServerName example.com


    ProxyRequests           Off
    ProxyPreserveHost       On
    ProxyPass               /       http://127.0.0.1:8983/
    ProxyPassReverse        /       http://127.0.0.1:8983/

    <Location />
            Require all granted
    </Location>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

   SSLProxyEngine          On
   SSLCertificateFile /etc/apache2/ssl/cert.pem
   SSLCertificateKeyFile /etc/apache2/ssl/privkey.pem
   Include /etc/apache2/ssl/options-ssl-apache.conf
   SSLCertificateChainFile /etc/apache2/ssl/chain.pem
</VirtualHost>
</IfModule>


来源:https://stackoverflow.com/questions/47214825/apache-solr-access-solr-server-by-https-domain-name

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!