I saw this post: Convert web.config to Caddyfile and it works to a point, the whole CSS and what not works, but the admincp does not, and i was wondering if there was any fix to it as the post it belonged to got closed back in 2017.
Im using Vbulletin 5.5.1 and the only issue i have is the rewrite of the admincp of:
rewrite /admincp (
index.php?routestring={uri}
}
And i would love some help to get it working.
The old config was as is
Send css calls directly to the correct file VBV-7807
section
Requires third-party plugin https://caddyserver.com/docs/expires
expires {
match .js$ 14d # 1209600 = 14 days
match .css$ 1y # 31536000 = 365 days - wow, seems a little long for CSS
match .(gif|jpg|jpeg|png|ttf|otf|woff|svg)$ 1m # 2592000 = 30 days#}
I was thinking about the fact that i could do
rewrite /admincp {
to /core/admincp
}
But that gives errors as well which i canât seem to fix. As well to that fix, it gives me this error
Invalid Page URL. If this is an error and the page should exist, please contact the system administrator and tell them how you got this message.
I remember taking a crack at that one, based off the .htaccess rather than the web.config. I donât recall whether the OP ever confirmed if it worked or not.
Can you elaborate on which errors youâre getting? Try to quote the exact output when you try it with the rewrite to index.php.
The /admincp path definitely needs to be rewritten to the root index.php, see the original .htaccess posted in the earlier thread:
# Because admincp is an actual directory.
RewriteRule ^(admincp/)$ index.php?routestring=$1 [L,QSA]
So with the whole index.php?routestring fix, i get the error
â Subject: Unit caddy.service has begun start-up
â Defined-By: systemd
â Support: systemd-devel Info Page
â
â Unit caddy.service has begun starting up.
Apr 14 19:02:14 vultr.guest caddy[9214]: 2019/04/14 19:02:14 /etc/caddy/sites-enabled/forums.fioregaming.com.conf:22 - Error during parsing: Wrong argument count or unexpected line ending after âindex.php?routestring={uri}â
Apr 14 19:02:14 vultr.guest systemd[1]: caddy.service: control process exited, code=exited status=1
Apr 14 19:02:14 vultr.guest systemd[1]: Failed to start Caddy HTTP/2 web server.
â Subject: Unit caddy.service has failed
â Defined-By: systemd
â Support: systemd-devel Info Page
â
â Unit caddy.service has failed.
â
â The result is failed.
When i try to use that exact line in the config of caddy. As well as, i use the nginx example of setting up a includes folder to sites-enabled while having a symbolic link from sites-available so that i can save time if i need to disable a site or enable a site.
Looks like I made a mistake when I wrote out that original Caddyfile by hand. The syntax for the target inside a rewrite block is actually to [target], not just the target on its own.
So, instead of this:
# Because admincp is an actual directory.
rewrite /admincp {
index.php?routestring={uri}
}
It should be this:
# Because admincp is an actual directory.
rewrite /admincp {
to index.php?routestring={uri}
}
So, it worked to redirect me to the admin cp, but it then redirects me for some reason to the main page giving me the error
Invalid Page URL. If this is an error and the page should exist, please contact the system administrator and tell them how you got this message.
I would give the url to my site for you to see, idk how i would make you a admin but it would allow you to see what i mean. Does this with anything admin related.
Heres the process as well step by step in pictures. To reproduce.
match .css$ 1y # 31536000 = 365 days - wow, seems a little long for CSS
match .(gif|jpg|jpeg|png|ttf|otf|woff|svg)$ 1m # 2592000 = 30 days
#}
tls {
dns cloudflare
}
}
The expire is in hash marks because the Cent OS 7 caddy does not come with the expire plugin. And i donât like building anything unless i absolutely have too.
RewriteEngine On
# In some cases where you have other mod_rewrite rules, you may need to remove the
# comment on the following RewriteBase line and change it to match your folder name.
# This resets the other mod_rewrite rules for just this directory
# If your site was www.example.com/forum, the setting would be /forum/
#RewriteBase /
#To redirect users to the secure version of your site, uncomment the lines below
#RewriteCond %{HTTPS} !=on
#RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# Send css calls directly to the correct file VBV-7807
RewriteRule ^css.php$ core/css.php [NC,L]
# Redirect old install path to core.
RewriteRule ^install/ core/install/ [NC,L]
# Main Redirect
RewriteCond %{REQUEST_URI} !\.(gif|jpg|jpeg|png|css)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?routestring=$1 [L,QSA]
# Because admincp is an actual directory.
RewriteRule ^(admincp/)$ index.php?routestring=$1 [L,QSA]
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/atom+xml \
text/javascript \
application/x-javascript \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType application/x-javascript A1209600
ExpiresByType text/javascript A1209600
ExpiresByType application/javascript A1209600
ExpiresByType text/css A31536000
ExpiresByType image/x-icon A2592000
ExpiresByType image/icon A2592000
ExpiresByType application/x-ico A2592000
ExpiresByType application/ico A2592000
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A1209600
ExpiresByType image/jpg A1209600
ExpiresByType image/png A1209600
ExpiresByType application/x-shockwave-flash A1209600
ExpiresByType font/ttf A2592000
ExpiresByType font/otf A2592000
ExpiresByType font/x-woff A2592000
ExpiresByType image/svg+xml A2592000
ExpiresByType font/truetype A2592000
ExpiresByType font/opentype A2592000
ExpiresByType application/x-font-woff A2592000
ExpiresByType application/vnd.ms-fontobject A2592000
</IfModule>
<IfModule mod_headers.c>
Header set Connection keep-alive
<filesmatch "\.(ico|flv|gif|swf|eot|woff|otf|ttf|svg)$">
Header set Cache-Control "max-age=2592000, public"
</filesmatch>
<filesmatch "\.(jpg|jpeg|png)$">
Header set Cache-Control "max-age=1209600, public"
</filesmatch>
<filesmatch "\.(eot|woff|otf|ttf|svg)$">
Header set Cache-Control "max-age=2592000, public"
</filesmatch>
# css and js should use private for proxy caching https://developers.google.com/speed/docs/best-practices/caching#LeverageProxyCaching
<filesmatch "\.(css)$">
Header set Cache-Control "max-age=31536000, public"
</filesmatch>
<filesmatch "\.(js)$">
Header set Cache-Control "max-age=1209600, public"
</filesmatch>
</IfModule>
#don't allow some files that shouldn't really be present to be directly accessed.
#note that attachements should never be directly accessed by the webserver because
#we have permissions on the that are checked in the PHP code.
<FilesMatch "(^#.*#|\.(bak|config|dist|inc|ini|log|gz|tar|zip|sh|sql|sw[op])|~)$">
Order allow,deny
Deny from all
Satisfy All
</FilesMatch>
I have to wonder if the index PHP itself is generating the 404 here? If so, why?
Iâm reluctant to advise modifying the rewrite to send login.php to /core/login.php without understanding why itâs structured that way or why the supplied .htaccessdoesnât do that. As far as I can tell, weâre replicating the .htaccess very faithfully right now.
Does vBulletin offer support? Can you query them as to why the login doesnât work when itâs rewritten to index.php (like their own .htaccess appears to do)?
As far as i know, they only support apache as the main approach to their software and nginx as a secondary since it became so popular, iâve queried them before i posted here and their official response was that âWe donât have anyone with experience with caddy in our support team, maybe you can try to the forumsâ to which the forumâs donât have anything either, so far anyway.
Normally if it were straightforward enough Iâd look into hosting it myself and doing some rapid troubleshooting but it looks like thereâs a hefty license fee to use vBulletin.
My strong recommendation at this point, given that their web server requirement seem a bit opaque and the support for Caddy nonexistent - just run it on Apache and reverse proxy to it from Caddy to get the best of both worlds (out of the box configuration/support + Caddyâs features).
This works great, i can access the admin cp due to apache using the Htaccess file and caddy serves it up with SSL and PHP
Thank you for your help!
Oh and itâs going to be great for others to see this for support if they ever wanna host Vbulletin sites as well!
As well as my configs.
example.com {
proxy / localhost:19999
}
caddy
<VirtualHost *:8080>
ServerAdmin Email Here
ServerName Domain or Sub Domain
DocumentRoot Document root where all your files are stored
ErrorLog Logging Directory for Errors.
CustomLog Logging Directory for access.combined files.
</VirtualHost>
Apache2
So, apache works, but using caddy, it proxies to localhost:8080, and doesnât seem to keep up with the fact that apache is hosted on 8080 and it doesnât try to see the website that is hosted on 8080