【问题标题】:Redirect Apache application to dot net core application将 Apache 应用程序重定向到点网核心应用程序
【发布时间】:2018-07-26 13:05:20
【问题描述】:

我有一个使用域 example.com 的服务器。我正在使用 apache 来运行这个 Web 服务器。我还安装了 Dot Net core 并将 Dot Net core 应用程序发布到 /var/www/app 位置。

我正在尝试使用 example.com/api 访问此应用程序

这是我在 000-default.conf 中尝试过的

<VirtualHost *:80>

    ServerAdmin root@example.com
    ServerName example.com
    ServerAlias www.example.com

    DocumentRoot /var/www/html

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

the below is what I hvae added for the application
<VirtualHost *:80>
       ServerName example.com/api
       ProxyPreserveHost On

       <Proxy *>
               Order allow, deny
               Allow from all
       </Proxy>
       ProxyPass / http://localhost:5000/
       ProxyPassReverse / http://localhost:5000/
</VirtualHost>

我也试过下面的配置。

<VirtualHost *:80>
       ServerName example.com/api
       redirect / http://localhost:5000/
</VirtualHost>

谁能帮我找出我做错了什么以及如何正确地做到这一点。

【问题讨论】:

    标签: apache .net-core webserver


    【解决方案1】:

    这可以通过使用下面的命令启用 proxy 和 proxy_http 来解决。

    a2enmod proxy
    a2enmod proxy_http
    

    还在虚拟主机内部配置了Proxy如下。

    <VirtualHost *:80>
        ServerAdmin root@example.com
        ServerName example.com
        ServerAlias www.example.com
        DocumentRoot /var/www/html
    
        #Below 3 lines worked
        ProxyPreserveHost On
        Proxypass "/api/" "http://localhost:5000/"
        ProxyPassReverse "/api/" "http://localhost:5000/"
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-13
      • 2017-04-17
      • 2015-12-13
      • 2014-10-27
      • 2014-09-25
      • 1970-01-01
      • 2017-03-22
      • 2018-05-14
      相关资源
      最近更新 更多