Apache Subdomain Root Queries

Description

  • The internal Tomcat server on which the webcam is listening on the 8080:

    "HTTP: // internal: 8080 / Foo-web service /"
    "Http: // internal: 8080 / foo site /"

  • An external Apache server is proxy requests for a subdomain:

    "http://foo.domain.com/"

  • Any subdomain root requests will be proxied to the foo-webapp website on Tomcat.

  • Any other requests will be proxied in the appropriate path / webapp

Use Case A

  • Inquiry:
    "http://foo.domain.com/index.html"

  • Proxy to:
    "Http: // internal: 8080 / foo site / index.html"

Use Case B

  • Inquiry:
    "http://foo.domain.com/webservice/listener.html?param1=foo¶m2=bar"

  • Proxy to:
    "HTTP: // internal: 8080 / Foo-web service / listener.html param1 = Foo & param2 = bar"

VirtualHost Definition

  • The current definition of a virtual host that satisfies use case B:

    <VirtualHost *:80> ServerName foo.domain.com ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ErrorLog /var/log/apache2/foo_error.log LogLevel warn CustomLog /var/log/apache2/foo_access.log combined # RewriteRules # ? # ProxyPass ProxyPreserveHost On ProxyPass / http://internal:8080/ ProxyPassReverse / http://internal:8080/ </VirtualHost> 

Attempt 1

  # RewriteRules RewriteEngine On RewriteRule ^/(.*) http://internal:8080/foo-website/$1 [P] 
  • Executing Example A Completed
  • Error using Case B

Attempt 2

  # RewriteRules RewriteEngine On RewriteRule ^/$ http://internal:8080/foo-website/$1 [P] 
  • Case Study B Satisfied
  • Case A is not fully satisfied
  • Index.html is loaded in the foo-website, but not one of the files in the js, img or css folders.
+4
source share
3 answers

ProxyPass rules are in order

  ProxyPass /webservice/ http://internal:8080/foo-webservice/ ProxyPassReverse /webservice/ http://internal:8080/foo-webservice/ ProxyPass /website/ http://internal:8080/foo-website/ ProxyPassReverse /website/ http://internal:8080/foo-website/ ProxyPass / http://internal:8080/foo-website/ ProxyPassReverse / http://internal:8080/foo-website/ 

There is no rewrite rule. Isn't that good enough?

+2
source

I think you need to use the first attempt, but include the QSA flag (add query string) in square brackets at the end of each RewriteRule directive.

0
source
  • I think that the problem with Attempt 2 (none of the files in the js, img or css folders were mapped) was a sign that my approach was wrong.

  • My solution now is to redirect any requests to the root to the foo-website .

      <VirtualHost *:80> ServerName foo.domain.com ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ErrorLog /var/log/apache2/foo_error.log LogLevel warn CustomLog /var/log/apache2/foo_access.log combined # RewriteRules RewriteEngine On RewriteRule ^/$ /foo-website/ [R] # ProxyPass ProxyPreserveHost On ProxyPass / http://internal:8080/ ProxyPassReverse / http://internal:8080/ </VirtualHost> 
  • This is not what I originally wanted, but I think this is permission.

0
source

Source: https://habr.com/ru/post/1403336/


All Articles