使用apache的闪亮服务器ProxyPass

时间:2018-08-13 18:02:32

标签: apache shiny reverse-proxy

我的闪亮服务器在我的VPS上运行没有任何问题(在Ubuntu上,通过Apache)。太好了。 :)但是,我现在尝试实现的是以下内容(很抱歉,此处使用的术语不正确,这对我来说是新的):

我想使用https://www.example.com:3838/appname(而不是通过https://www.example.com/appname共享我的应用程序(这称为端口转发吗?又称为“摆脱端口3838”)。

请注意,我不希望闪亮的服务器“接管”我的主页,因为https://www.example.com服务于我自己的个人站点。

我尝试将Chris Beeley共享的代码块包含在/etc/apache2/sites-enabled/000-default-le-ssl.conf中,但这不起作用。但是,在某种程度上可行的是,如果我按如下方式调整代码

原始代码

ProxyPreserveHost On
ProxyPass /shinyapps http://0.0.0.0:3838/shinyapps
ProxyPassReverse /shinyapps http://0.0.0.0:3838/shinyapps
ServerName localhost

调整后的代码

ProxyPreserveHost On
ProxyPass /foo http://0.0.0.0:3838/foo
ProxyPassReverse /foo http://0.0.0.0:3838/foo
ServerName localhost

是的,现在可以通过www.example.com/foo访问我名为foo的应用程序;但这意味着我需要在此代码块中添加所有应用程序的名称。

有什么建议吗?谢谢。

此外,对于这个问题,我很抱歉。

PS。所有与http的传入连接都已重定向到https

2 个答案:

答案 0 :(得分:2)

应该可以:

ProxyPreserveHost On
ProxyPass /(.*)$ http://0.0.0.0:3838/$1
ProxyPassReverse /(.*)$ http://0.0.0.0:3838/$1
ServerName localhost

查看此链接:https://httpd.apache.org/docs/trunk/rewrite/intro.html

答案 1 :(得分:1)

我认为您误解了URL的结构方式。您需要指向

add_action( 'woocommerce_checkout_order_review', 'reordering_checkout_order_review', 1 );
function reordering_checkout_order_review(){
    remove_action('woocommerce_checkout_order_review','woocommerce_checkout_payment', 20 );
    add_action( 'woocommerce_checkout_order_review', 'custom_checkout_payment', 8 );
    add_action( 'woocommerce_checkout_order_review', 'custom_checkout_place_order', 20 );
}

function custom_checkout_payment() {
    $checkout = WC()->checkout();
    if ( WC()->cart->needs_payment() ) {
        $available_gateways = WC()->payment_gateways()->get_available_payment_gateways();
        WC()->payment_gateways()->set_current_gateway( $available_gateways );
    } else {
        $available_gateways = array();
    }

    if ( ! is_ajax() ) {
        // do_action( 'woocommerce_review_order_before_payment' );
    }
    ?>
    <div id="payment" class="woocommerce-checkout-payment-gateways">
        <?php if ( WC()->cart->needs_payment() ) : ?>
            <ul class="wc_payment_methods payment_methods methods">
                <?php
                if ( ! empty( $available_gateways ) ) {
                    foreach ( $available_gateways as $gateway ) {
                        wc_get_template( 'checkout/payment-method.php', array( 'gateway' => $gateway ) );
                    }
                } else {
                    echo '<li class="woocommerce-notice woocommerce-notice--info woocommerce-info">';
                    echo apply_filters( 'woocommerce_no_available_payment_methods_message', WC()->customer->get_billing_country() ? esc_html__( 'Sorry, it seems that there are no available payment methods for your state. Please contact us if you require assistance or wish to make alternate arrangements.', 'woocommerce' ) : esc_html__( 'Please fill in your details above to see available payment methods.', 'woocommerce' ) ) . '</li>'; // @codingStandardsIgnoreLine
                }
                ?>
            </ul>
        <?php endif; ?>
    </div>
    <?php
}

function custom_checkout_place_order() {
    $checkout          = WC()->checkout();
    $order_button_text = apply_filters( 'woocommerce_order_button_text', __( 'Place order', 'woocommerce' ) );
    ?>
    <div id="payment-place-order" class="woocommerce-checkout-place-order">
        <div class="form-row place-order">
            <noscript>
                <?php esc_html_e( 'Since your browser does not support JavaScript, or it is disabled, please ensure you click the <em>Update Totals</em> button before placing your order. You may be charged more than the amount stated above if you fail to do so.', 'woocommerce' ); ?>
                <br/><button type="submit" class="button alt" name="woocommerce_checkout_update_totals" value="<?php esc_attr_e( 'Update totals', 'woocommerce' ); ?>"><?php esc_html_e( 'Update totals', 'woocommerce' ); ?></button>
            </noscript>

            <?php wc_get_template( 'checkout/terms.php' ); ?>

            <?php do_action( 'woocommerce_review_order_before_submit' ); ?>

            <?php echo apply_filters( 'woocommerce_order_button_html', '<button type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '">' . esc_html( $order_button_text ) . '</button>' ); // @codingStandardsIgnoreLine ?>

            <?php do_action( 'woocommerce_review_order_after_submit' ); ?>

            <?php wp_nonce_field( 'woocommerce-process_checkout', 'woocommerce-process-checkout-nonce' ); ?>
        </div>
    </div>
    <?php
    if ( ! is_ajax() ) {
        do_action( 'woocommerce_review_order_after_payment' );
    }
}

已完成操作,但是foo是应用程序的目录的名称。

因此,将您拥有的所有应用程序文件夹放入foo中。

现在该网址为

ProxyPass /foo http://0.0.0.0:3838/foo

等等。