0

I have an apache server, a unique domain name and multiple tomcat instances, here is my actual config :

<VirtualHost *:80>
ServerName my.domain.com
...
ProxyPass /sample_1 ajp://127.0.0.1:8009/sample_1 
ProxyPass /sample_2 ajp://127.0.0.1:8009/sample_2 
ProxyPass /sample_3 ajp://127.0.0.1:8014/sample_3
ProxyPass /sample_4 ajp://127.0.0.1:8019/sample_4
....
CustomLog   logs/my_access_log combined
ErrorLog    logs/my_error_log
</VirtualHost>

Now, I would like to use a CustomLog for each tomcat instance, I tried to put each ProxyPass directive in a separate virtualhost, but I got 403 error except for the virtualhost on the top according to httpd -S output.

I don't like to remove the ServerName directive, because the service will be available throug the IP address.

Help please

Belgacem
  • 3
  • 1

1 Answers1

2

You can use the SetEnvIf directive in combination with conditional logging to log specific requests to different log files.

<VirtualHost *:80>

    ServerName my.example.com
    ...

    SetEnvIf Request_URI "/sample_1.*" sample_1
    SetEnvIf Request_URI "/sample_2.*" sample_2

    CustomLog   logs/my_access_log_sample_1 combined env=sample_1
    CustomLog   logs/my_access_log_sample_2 combined env=sample_2
    CustomLog   logs/my_access_log combined
    ErrorLog    logs/my_error_log

</VirtualHost>
Daniel Ferradal
  • 2,415
  • 1
  • 8
  • 13
HBruijn
  • 77,029
  • 24
  • 135
  • 201