last day (14 days later) » 

12:57 AM
1
Q: AliasMatch With Regex NotWorking in Apache 2.4

RanPaulI used to have Alias as below for /CollabPortal14300 which was working fine Alias /CollabPortal14300 D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/ Alias /dc/api/entity/EmailDocument/\d+/DocumentVersion/1\.0 D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/core/html...

 
Do you have to use ipv6? Check error logs, not access logs
Your requests to server are made through ipv6, look at the address fe80::f48e:b1a2:4f75:7c9c As you can see, the AliasMatch is working. The problem is in the config of the server that prevents access to the folder. Do you have any .htaccess in it?
 
@Cheery I didnt notice that, How should I handle IPV6 in my scenario?
 
You can use ipv6, but there might be some other problems due to the server's config. Again, authz_core:error shows that the problem is with authz_core module. It should work fine with FilesMatch, but may be you have some other config not listed here. Try to remove slash at the end of the path in AliasMatch
Also.. Directives in the configuration files are case-insensitive, but arguments to directives are often case sensitive. Try to change to granted
 
@Cheery changed to granted still its not working, what other config files you want me to add here?
 
Did you restart apache after changes? check for .htaccess file in that folder or in the folders above it - httpd.apache.org/docs/current/howto/htaccess.html
 
12:57 AM
Yes I did restart my apache and I am not using .htaccess
 
D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/ remove slash at the end. I do not see other reasons in the listed config. Also, check in access log what was requested at Thu Nov 13 18:21:18.278759 2014 by fe80::f48e:b1a2:4f75:7c9c:58633
 
removed slash at the end, that didnt work either :(
Hello Cheery
 
Add to config LogLevel info authz_core:trace6 and check the logs for specifics of the problem.
it should show more details related to that problem.
 
where should i add it? above the Directory ?
 
Yes, or inside
 
1:00 AM
okay let me try that
[Thu Nov 13 19:01:20.799620 2014] [ssl:info] [pid 71480:tid 332] AH01914: Configuring server dc-rpalle7:443 for SSL protocol
[Thu Nov 13 19:01:20.802620 2014] [ssl:info] [pid 71480:tid 332] AH02568: Certificate and private key dc-rpalle7:443:0 configured from D:/Dev/tools/apache-httpd-2.4.9/conf/cert-dcrpalle7/dc-rpalle7.crt and D:/Dev/tools/apache-httpd-2.4.9/conf/cert-dcrpalle7/dc-rpalle7.key
[Thu Nov 13 19:01:21.331620 2014] [ssl:info] [pid 71480:tid 332] AH01914: Configuring server dc-rpalle7:443 for SSL protocol
[Thu Nov 13 19:01:35.281620 2014] [authz_core:debug] [pid 70140:tid 912] mod_authz_core.c(799): [client fe80::f48e:b1a2:4f75:7c9c:60257] AH01626: authorization result of Require all denied: denied, referer: https://dc-rpalle7/CollabPortal/admin/index.do
[Thu Nov 13 19:01:35.281620 2014] [authz_core:debug] [pid 70140:tid 912] mod_authz_core.c(799): [client fe80::f48e:b1a2:4f75:7c9c:60257] AH01626: authorization result of <RequireAny>: denied, referer: https://dc-rpalle7/CollabPortal/admin/index.do
there are the authz_core:trace6 logs
 
It is not related to the AliasMatch
What url is requested (from access logs)
 
Am a very beginner to Apache thing, I dont really understand much from logs
I hit dc-rpalle7/CollaboPortal/index.do which took me to login page
I entered my credentials then I went into the application
 
And .js,.css and so on files are not loaded?
 
yes
 
Just take ip fe80::f48e:b1a2:4f75:7c9c:60260, take time Thu Nov 13 19:01:35.283620 2014 and check in access log what was requested.
 
1:13 AM
page loaded without any images, js and css
okay
 
Also, are you sure that you are showing config of https site, not regular http version
 
fe80::f48e:b1a2:4f75:7c9c - - [13/Nov/2014:19:01:31 -0600] "GET / HTTP/1.1" 302 222
fe80::f48e:b1a2:4f75:7c9c - - [13/Nov/2014:19:01:31 -0600] "GET /CollabPortal HTTP/1.1" 302 -
fe80::f48e:b1a2:4f75:7c9c - - [13/Nov/2014:19:01:31 -0600] "GET /CollabPortal/ HTTP/1.1" 302 -
fe80::f48e:b1a2:4f75:7c9c - - [13/Nov/2014:19:01:31 -0600] "GET /CollabPortal/index.do HTTP/1.1" 200 2144
fe80::f48e:b1a2:4f75:7c9c - - [13/Nov/2014:19:01:31 -0600] "GET /CollabPortal/passport.manifest.jsp HTTP/1.1" 200 1699
fe80::f48e:b1a2:4f75:7c9c - - [13/Nov/2014:19:01:31 -0600] "GET /CollabPortal14300/core/v2/ico/favi
nope am not using regular http
you can verify it in the screenshot
By the way I changed my regex in Aliasmatch as below
AliasMatch /CollaborationPortal(?:\d{5})? D:/Dev/Projects/CollaborationPortal/CollaborationPortal/target/CollaborationPort‌​al
 
Screenshot does not show the images URL. May be you are using full URL for them, leading to http version of the site. Because I do not see any https symbol in the address bar.
 
AliasMatch /CollabPortal(?:\d{5})? D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal
 
Ok, let me try to reproduce a problem.
 
1:19 AM
I can see it in the screenshot I sent you
 
I was talking about images/css/js URLs
 
ohh okay gotcha
 
something is not good with config, testing
 
let me give you my httpd.conf file
ServerRoot "D:/Dev/tools/apache-httpd-2.4.9"
Listen 80

LoadModule access_compat_module modules/mod_access_compat.so
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule auth_form_module modules/mod_auth_form.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
 
This is a config of http version of the website.
 
1:32 AM
but if I use Alias /CollabPortal14300 instedad of ALiasMatch /CollabPortal(?:\d{5})? everything works fine as expected
 
Do you see Listen 80? https config is not here... probably in httpd-ssl.conf
 
okay i'll update httpd-ssl.conf
Listen 443
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
SSLPassPhraseDialog builtin

SSLSessionCache "shmcb:C:/DC/Passport/apache/logs/ssl_scache(512000)"

<VirtualHost *:443>
DocumentRoot "D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/"
ServerName dc-rpalle7
ServerAdmin noone@DC.com
ErrorLog "D:/Dev/tools/apache-httpd-2.4.9/logs/error.log"
TransferLog "D:/Dev/tools/apache-httpd-2.4.9/logs/access.log"
 
This is what responding on requests to https.
 
Yes
 
No, I'm telling you that what you have in part with Listen 80 is not a https config of the server. But the second config is.
<VirtualHost *:443> inside is a configuration of apache that responds on https requests.
 
1:38 AM
Okay, Now am able to understand it little bit
what part of the configuration you thing its doing wrong
 
Try to copy the part with AliasMatch and so on into the ssl part. Sorry, can not remember right now whether the default settings are applied automatically to virtualhosts, but I think no..
You thing without numbers is working due to ProxyPass /CollabPortal ajp://localhost:8010/CollabPortal
 
Shall I copy just AliasMatch Part or AliasMatch with Directory?
 
Everything. Alias defines the alias and directory defines settings for it.
 
okay let me put it in ssl conf
 
Inside of <VirtualHost *:443>
Moreover, your documentroot is pointing to DocumentRoot "D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/"
 
1:51 AM
Copied AliasMatch after Directory block in ssl, that didnt work either
;(
 
Did you restart the server?
 
yes i did
 
Show new ssl config
 
Listen 443
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
SSLPassPhraseDialog builtin

SSLSessionCache "shmcb:C:/DC/Passport/apache/logs/ssl_scache(512000)"

<VirtualHost *:443>
DocumentRoot "D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/"
ServerName dc-rpalle7
ServerAdmin noone@DC.com
ErrorLog "D:/Dev/tools/apache-httpd-2.4.9/logs/error.log"
TransferLog "D:/Dev/tools/apache-httpd-2.4.9/logs/access.log"
 
The thing is that documentroot is already pointing to the same folder. you, probably, do not need alias, but a rewriterule for that.
Ok, found the reason.. did not try aliasmatch before, but..
 
2:01 AM
all the static resources are referenced via /CollabPortal14300 url pattern thats why I introduced RegEx with AliasMatch
what is that?
 
AliasMatch /CollabPortal\d{5}?/(.*) D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/$2
sorry, change $2 to $1
I removed parentheses around \d{5}
 
where should I add it in ssl file?
 
you can try to put it outside (may be you are requesting by http images and so on). If it does not help - yes, in ssl
I checked it with my config - it works.
 
outside mean above <VirtualHost *:443> block in ssl conf file?
 
Sorry, never used AliasMatch before. Also, you do not need it here. Something like RewriteRule ^/CollabPortal\d{5}?/(.*) /$1 [L] should work too.
Make changes where you were trying to do in the beginning, than in virtualhost part
 
2:06 AM
okay, let me try in the httpd.conf file if that doesnt work i'll try it in ssl conf
 
ok
I tried those in virtual machine and they worked.
 
added in the httpd.conf file that didnt work
let me add it in ssl conf file
<VirtualHost *:443>
DocumentRoot "D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/"
ServerName dc-rpalle7
ServerAdmin noone@DC.com
ErrorLog "D:/Dev/tools/apache-httpd-2.4.9/logs/error.log"
TransferLog "D:/Dev/tools/apache-httpd-2.4.9/logs/access.log"

SSLEngine on
SSLProxyEngine on
#SSLProtocol -ALL +TLSv1 +TLSv1.1 +TLSv1.2
#SSLCipherSuite HIGH:MEDIUM:LOW:-aNULL
# no cert prompt on this vhost
SSLVerifyClient optional
SSLVerifyDepth 3

SSLCertificateFile "D:/Dev/tools/apache-httpd-2.4.9/conf/cert-dcrpalle7/dc-rpalle7.crt"
added in the ssl conf as above, that didnt work either
 
AliasMatch /CollabPortal(?:\d{5})? D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal this is not what I asked to write
RewriteRule ^/CollabPortal\d{5} /$1 [L] I did not check it
and wrote it in different way
Either RewriteRule ^/CollabPortal\d{5}?/(.*) /$1 [L], but I did not check it
or AliasMatch /CollabPortal\d{5}?/(.*) D:/Dev/Projects/CollabPortal/CollabPortal/target/CollabPortal/$1
 
let me try again
 
/CollabPortal\d{5}?/(.*) question mark supposed to work for /CollabPortal/ without numbers, but you are already proxying it with ProxyPass /CollabPortal ajp://localhost:8010/CollabPortal.
 
2:22 AM
rewrite rule worked
:D
Thanks a ton
you are awesome
You ROCK.....!!
I've been trying to solve this for the past 2 days
 
You were looking in the wrong place, configs for port 80 and 443 are in different places
 
Yes am very amateur and this is my first task on Apache
 
This may still need some tuneup, as you are proxying some urls, also it does not limit access only to images, css, js files, but may interfere with other urls in https
 
I tried to look it up on web but nobody has the right answer for the solution
 
Because they did not know that you are dealing with https, but modifying http.
 
2:26 AM
Yes I want to limit the access to only images, css, js files
 
Add FilesMatch, but it may affect other proxying requests. you will need it probably within httpd.apache.org/docs/current/mod/core.html#locationmatch
So that other requests will go is previously. LocationMatch to what you want, denied inside and filesmatch with granted in it too
 
That sounds a bit complicated, can you help me with LocationMatch ?
 
it is the same as before with aliasmatch.
<LocationMatch ^/CollabPortal\d{5}>
Require all denied
<FilesMatch "\.(gif|jpe?g|jpg|png|js|css|ico)$">
Require all granted
</FilesMatch>
ExpiresActive On
ExpiresByType image/gif "access plus 10 years"
ExpiresByType image/png "access plus 10 years"
ExpiresByType text/css "access plus 10 years"
ExpiresByType text/javascript "access plus 10 years"
ExpiresByType application/javascript "access plus 10 years"
</LocationMatch>

Did not test it.
 
Shall I copy it below the RewriteRule ^/CollabPortal\d{5}?/(.*) /$1 [L] in ssl conf file?
 
It should not matter
 
2:35 AM
The Apache service named reported the following error:
>>> <FilesMatch> cannot occur within <LocationMatch> section .
error while trying to restart apache
 
I understand. Location is for URL, Filesmatch for filesystem
Then instead of LocationMatch should be Directory, without any match. As you've done for the alias before, just copy the directory part.
 
okay
page loads with images, js and css files
but how do i test whether its giving access to only images js and css files
 
Make a request to any other file, even non-existing
There still might be a slight problem as your DocumentRoot is the same as that folder. But may be not and it will work as expected.
 
I got Forbidden

You don't have permission to access /CollabPortal14300/css/custom.txt on this server.
then am getting the css on web page
 
ok
 
2:47 AM
you think its working fine?
are there any other tests i can try?
 
the time will show as I do not know all the details about other requests that might come to the server
 
I think its the fix..I really appreciate your effort...
Thanks a ton
 
you are welcome
 
by the way myself Rana may I know u?
Can you post your answer, I'll accept it
 

last day (14 days later) »