简体   繁体   English

Apache上的反向代理(用于QNAP)

[英]Reverse proxy on Apache (for QNAP)

As I cannot access to ports other than 80 and 443 at work, I would like to make accessible some resources using Apache on my QNAP. 由于我在工作时无法访问80和443以外的端口,因此我想使用QNAP上的Apache来访问某些资源。

In particular I would like to: 我特别希望:

  1. set a Virtual Host (using sub1.domain.com) to connect to a service running on the same host (my QNAP) ( http://localhost:58000 ) 设置虚拟主机(使用sub1.domain.com)以连接到在同一主机(我的QNAP)上运行的服务( http:// localhost:58000
  2. set a Virtual Host (using sub2.domain.com) to connect to another host within the LAN ( http://192.168.1.1:78080 ) 设置一个虚拟主机(使用sub2.domain.com)以连接到局域网( http://192.168.1.1:78080 )中的另一个主机
  3. set a Virtual Host (using sub3.domain.com) to connect to an external website (eg https://www.google.com ) 设置虚拟主机(使用sub3.domain.com)以连接到外部网站(例如https://www.google.com

Beside activating proxy_module and proxy_ssl_module (and changing DNS accordingly), I have thought to use the following line codes on httpd-vhosts-user.conf (for 1. and 2.) and on httpd-ssl-vhosts-user.conf (for 3.): 除了激活proxy_module和proxy_ssl_module(并相应地更改DNS)之外,我还考虑在httpd-vhosts-user.conf(用于1.和2)和httpd-ssl-vhosts-user.conf(用于)上使用以下行代码。 3):

General sections (FYI): 一般章节(FYI):

/etc/config/apache/extra/httpd-vhosts-user.conf /etc/config/apache/extra/httpd-vhosts-user.conf

    NameVirtualHost *:80

    <VirtualHost _default_:80>
       DocumentRoot "/share/Web"
    </VirtualHost>

/etc/config/apache/extra/httpd-ssl-vhosts-user.conf /etc/config/apache/extra/httpd-ssl-vhosts-user.conf

    NameVirtualHost *:443

    <VirtualHost _default_:443>
       DocumentRoot "/share/Web"
    </VirtualHost>
  1. Virtual Host to connect to the service running on http://localhost:58000 虚拟主机连接到在http:// localhost:58000上运行的服务

     <VirtualHost *:80> ServerName sub1.domain.com DocumentRoot "/share/Web/sub1" ProxyPreserveHost On ProxyRequests Off ProxyVia Off ProxyPass /sub1 http://localhost:58000 ProxyHTMLURLMap http://localhost:58000 /sub1 <Location /sub1> ProxyPassReverse / ProxyHTMLInterp On ProxyHTMLURLMap / /sub1 RequestHeader unset Accept-Encoding </Location> <Proxy *> AddDefaultCharset off Order deny,allow Deny from all Allow from all </Proxy> <Directory "/share/Web/sub1"> Options FollowSymLinks MultiViews Order allow,deny Allow from all </Directory> </VirtualHost> 
  2. Virtual Host to connect to other service running on http://192.168.1.1:78080 虚拟主机连接到在http://192.168.1.1:78080上运行的其他服务

     <VirtualHost *:80> ServerName sub2.domain.com DocumentRoot "/share/Web/sub2" ProxyPreserveHost On ProxyRequests Off ProxyVia Off ProxyPass /sub2 http://192.168.1.1:78080 ProxyHTMLURLMap http://192.168.1.1:78080 /sub2 <Location /Asus> ProxyPassReverse / ProxyHTMLInterp On ProxyHTMLURLMap / /sub2 RequestHeader unset Accept-Encoding </Location> <Proxy *> AddDefaultCharset off Order deny,allow Deny from all Allow from all </Proxy> <Directory "/share/Web/sub2"> Options FollowSymLinks MultiViews Order allow,deny Allow from all </Directory> </VirtualHost> 
  3. Virtual Host to connect to the given external site (eg google) [credits to kamal @ serverfault.com ] 虚拟主机可连接到给定的外部站点(例如google)[贷记给kamal @ serverfault.com ]

     <VirtualHost *:443> ServerName sub3.domain.com ProxyPreserveHost On <Proxy *> AddDefaultCharset off Order deny,allow Deny from all Allow from all </Proxy> ProxyPass /sub3 https://www.google.com/ ProxyHTMLURLMap https://www.google.com /sub3 <Location /sub3> ProxyPassReverse / ProxyHTMLInterp On ProxyHTMLURLMap / /sub3 RequestHeader unset Accept-Encoding </Location> </VirtualHost> 

However none of these Virtual Hosts work (I have a connection fail or endless loading). 但是,这些虚拟主机都不起作用(我的连接失败或加载无穷)。

Could someone please help me reviewing the code? 有人可以帮我查看代码吗?

Thank you very much in advance! 提前非常感谢您!

Here are the answers: 答案如下:

  1. Virtual Host to connect to the service running on http://localhost:58000 虚拟主机连接到在http:// localhost:58000上运行的服务

     <VirtualHost *:80> ServerName sub1.domain.com ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> <Location /> Order allow,deny Allow from all </Location> ProxyPreserveHost On ProxyPass / http://localhost:58000/ ProxyPassReverse / http://localhost:58000/ ProxyStatus On </VirtualHost> 
  2. Virtual Host to connect to other service running on http://192.168.1.1:78080 虚拟主机连接到在http://192.168.1.1:78080上运行的其他服务

     <VirtualHost *:80> ServerName sub2.domain.com ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> <Location /> Order allow,deny Allow from all </Location> ProxyPreserveHost On ProxyPass / http://192.168.1.1:78080/ ProxyPassReverse / http://192.168.1.1:78080/ ProxyStatus On </VirtualHost> 
  3. Virtual Host to connect to the given external site (eg google in HTTP only) 虚拟主机可连接到给定的外部站点(例如,仅HTTP中的google)

     <VirtualHost *:80> ServerName sub3.domain.com DocumentRoot "/share/Web" <Directory "/share/Web"> Options Indexes Includes FollowSymLinks AllowOverride All Order Allow,Deny Allow from all Deny from none </Directory> <Location /> ProxyPass http://google.com/ ProxyPassReverse http://google.com/ </Location> </Virtualhost> 

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

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