简体   繁体   English

结合 r-handler 和 tls

[英]Combine r-handler and tls

Is it possible to provide the Apache R-mod via TLS directly?是否可以直接通过 TLS 提供 Apache R-mod? Without the need to set up a reverse proxy?无需设置反向代理?

I'm trying to set up an OpenCPU instance without the typical reverse proxy configuration.我正在尝试设置一个没有典型反向代理配置的 OpenCPU 实例。 It should be accessible via HTTPS and HTTPS only.它应该只能通过 HTTPS 和 HTTPS 访问。

Whenever I try to enable the TLS/SSL engine, Apache ignores that and on port 443 I'll get a header missmatch as HTTP is delivered over port 443.每当我尝试启用 TLS/SSL 引擎时,Apache 都会忽略它,并且在端口 443 上,由于 HTTP 是通过端口 443 传送的,因此我会得到标头不匹配。

<IfModule mod_ssl.c>
SSLStaplingCache "shmcb:${APACHE_LOG_DIR}/stapling-cache(150000)"
<IfModule mod_R.c>

    RSourceOnStartup "/usr/lib/opencpu/rapache/onstartup.R"

    <Location /ocpu>
        SSLEngine on
        SSLUseStapling on
        SSLCertificateFile  /etc/ssl/xxx.pem
        SSLCertificateKeyFile /etc/ssl/private/xxx.key
        SSLCertificateChainFile /etc/ssl/certs/chain.pem

        SetHandler r-handler
        RHandler opencpu:::rapachehandler
        SetOutputFilter DEFLATE
        SetInputFilter DEFLATE
    </Location>

    Alias /favicon.ico /usr/lib/opencpu/rapache/favicon.ico
    Alias /robots.txt /usr/lib/opencpu/rapache/robots.txt

    # Increase prefork defaults
    <IfVersion >= 2.4>
        #StartServers 10
        MaxConnectionsPerChild 200
        <Directory /usr/lib/opencpu/rapache>
            Require all granted
        </Directory>
    </IfVersion>

</IfModule>

It seems that the Location /ocpu is valid for both VirtualHosts, the one for HTTP and HTTPS.似乎位置 /ocpu 对两个 VirtualHosts 都有效,一个对 HTTP 和 HTTPS 有效。

So it suffices to redirect HTTP to HTTPS in 000-default.conf and to correctly set up TLS in the default-ssl.conf.因此,在 000-default.conf 中将 HTTP 重定向到 HTTPS 并在 default-ssl.conf 中正确设置 TLS 就足够了。

<VirtualHost *:80>
    ServerName xxx
    ServerAdmin xxx

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

    Redirect / https://xxx/

</VirtualHost>

And

# cat default-ssl.conf 
<IfModule mod_ssl.c>
    SSLStaplingCache "shmcb:${APACHE_LOG_DIR}/stapling-cache(150000)"
    LogLevel Debug
    <VirtualHost *:443>
        ServerName xxx
        ServerAdmin xxx

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

        SSLEngine on
        SSLUseStapling on

        SSLCertificateFile  /etc/ssl/certs/xxx.pem
        SSLCertificateKeyFile /etc/ssl/private/xxx.key
        SSLCertificateChainFile /etc/ssl/certs/xxx.pem

        DocumentRoot /var/www/html

    </VirtualHost>
</IfModule>

No need to change anything in the opencpu.conf.无需更改 opencpu.conf 中的任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM