-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test on multisite #8
Comments
when will this point be back at roadmap? |
So it was noticed, that I took it off the roadmap :) Currently the plugin will immediately deactivate, if it detects it runs in multi site configuration. The only reason I do this, is because I have not tested multi site AT ALL. To remove that behaviour, you must edit one of the plugin files manually. In plugins/webp-express/lib/activate-first-time.php, remove the following code:
I look forward to hear how it goes... |
It works on the main site, doesn't seem to work on "child" sites. Might me just me though, I'm using nginx and maybe the routing is just off. |
Works fine for me so far, if the plugin is not network activated, but activated on the child website independently. |
@feeltheice77, @ktmn and @portalzine: I have multisite functionality in beta. To test it, you must:
Please report test results (good or bad). Related threads / topics / issues: |
I updated to development version. Network activated it and now the settings page is in network admin and not on any other dashboards. All good there. The main site serves webps, but the child sites (subdirectory) don't. For example: "Direct link/non-wp image" such as My nginx conf has this:
Does the |
The source parameter in Query String is currently only used when the "Do not pass source in Query String" is disabled, which currently only can be done in Tweaked mode. I'm considering changing that behaviour because it seems that option to pass source in QS is needed in more cases than I thought. To try if it works with source, you can switch to Tweaked mode and disable that option. Look for this code:
change it to:
|
I haven't tested multisite with Nginx. Forgot about that. What are the nginx configuration rules that you use for Multisite? |
Using the Nginx Helper plugin, the multisite gist of it is this:
|
Switching to Tweaked mode and commenting out the |
Yeah, it seems that these rules are for serving static files directly. The rules probably takes the request before our rules gets to process. Solving this probably requires some trickery. I have other stuff in my hands, but shall return to this |
Btw: Does the Alter HTML functionality work ? |
With a custom theme (Sage based) mostly not - only image in widget area was converted (created with Monster Widget), but not image block in post content. But with 2019 seemed like it worked everywhere, but started getting 404's for WC product page images, so not compatible with that I don't think. |
As for the nginx config, this is more similar to the conf I'm using. It's got this part for multisite:
and webp code I added after it:
The So I moved the webp part above it and now the issue was with the Bad: Once I added some PHP to strip out the if (!file_exists($source)) {
header('X-WebP-Express-Error: Source file not found!', true);
echo 'Source file not found!';
exit;
} would do the trick too. |
I cannot add filter because webp-on-demand. php does not run Wordpress init. I'm thinking that I for NGINX multisite could allow webp-on-demand.php to do some heuristics
So when it receives "BAD" (works for GOOD as well): It could first subtract document root: and then it could skip folders until it reaches "wp-content": and then it could append it to document root: Perhaps only for NGINX and multisite I can easily have webp-on-demand.php know that we are running in multisite, by storing that fact in the config ( The method could perhaps also be used for Apache sites. Perhaps optionally |
Another approach could be to try to come up with a rewrite rule that inserts the path from the matched path instead of the server variables. The path will be relative, so webp-on-demand.php must then accept relative paths too. Something like this:
I'm not sure if that will match the subsite as well. In case it does, one could do something like this:
|
I'm not good enough with nginx or regex to make it work in server config.
Experiemented with this a little, couldn't make it work. I don't know what the best way would be for different setups but for me, this could work: On a child site What about passing Then Something like this: if(isset($_GET['source-root']) && isset($_GET['source-uri'])) {
$wp_content = isset($_GET['wp-content']) ? $_GET['wp-content'] : 'wp-content';
$parts = explode('/', $_GET['source-uri']);
foreach($parts as $index => $part) {
if($part !== $wp_content) {
unset($parts[$index]);
} else {
break;
}
}
$source = $_GET['source-root'] . '/' . implode('/', $parts);
}
When push comes to shove you could do a non-wordpress filter, like look for a specifically named file in |
Both ideas sounds good... |
It seems there is no reason to pass source-root, as document root should be the same in nginx conf and in the script. Even before this, I had been thinking about introducing "source-rel" (relative path from document root to source file). Passing the complete path increases the risk of problems of firewall blocking. I think I'll go with "source-rel" rather than "source-uri". I think implementing the filter in the script, and activating it by name through the QS will do. It is simpler and doesn't require any security measures. Ie: |
Sounds good, as long as |
I see. This stuff doesn't work when upload folder has been moved or wp-content folder has been moved (not just renamed), but I guess it solves the needs of the majority of the minority that has these kinds of needs. |
…ring. TODO: also use this setting for webp-realizer.php. Also added source-rel-filter=discard-parts-before-wp-content filter as discussed in #8
I have added the option to discard parts before wp-content. To test, please update to master. Note that the vendor library isn't distributed here on github, so make sure to copy the vendor folder over. There is now a new option "Method for passing filename" in the "Redirect rules" section. You must select "Pass through query string (relative)" |
I just discovered that you were using Perhaps changing that solves it so we don't need the filter after all? |
Except it broke static/non-wp images, by looking for if (isset($_GET['source-rel-filter'])) {
$parts = explode('/', $srcRel);
$wp_content = isset($_GET['wp-content']) ? $_GET['wp-content'] : 'wp-content';
if ($_GET['source-rel-filter'] == 'discard-parts-before-wp-content' && in_array($wp_content, $parts)) {
foreach($parts as $index => $part) {
if($part !== $wp_content) {
unset($parts[$index]);
} else {
break;
}
}
$srcRel = implode('/', $parts);
}
} (Moved
The value seems to be dynamic based on rewrites and whatnot. Logging it at the "end":
the value ends up as
block, while in there it's still
but I'm not quite sure how it works and the webp-on-demand.php security: I'm just wondering, how safe is it to use the
or would that leak somewhere in the serving process? Delivering the correct password to check against to |
Altered your change a bit, so the code for 'discard-parts-before-wp-content' filter is contained inside the
|
Yes security. I have also wondered if the script could be misused somehow... |
Nice, thanks! |
I tried inserting this:
It results in a 404 when webp-on-demand is requested directly. |
Perhaps a password is the simplest solution. It could be stored in the configuration file as well as be handed over in the query string. The query string cannot be detected because the redirect is internal (both on Nginx and in Apache). The password could be autogenerated. Nginx users, who will need to know it, would be able to view it by opening |
Opening a new issue for that |
It seems we can just insert these lines in the beginning of if (preg_match('#webp-on-demand.php#', $_SERVER['REQUEST_URI'])) {
echo 'Direct access is not allowed';
exit;
} |
I'm hoping to release 0.12.0 tomorrow... |
Tomorrow from now ;) |
@ktmn @rosell-dk I tried to run webp express on multisite (subdir mode) with configs from FAQ, but it doesn't work. What I should add to nginx config? |
Any news on this one? I did read through this issue, but I did not find the proper nginx rules for multisite install (in my case subdomain, but that should make any difference I guess) |
All I got is this one rule (and it's quite high up in the config file) but I'm using an older version to make it work. What is your conf, what errors are you getting? |
Hi guys, I'm on WP-Engine (which is on NGINX I guess), is there any solution to make the plugin work on child sites? I use sub-directories. |
I second that– would be great to be able to install this plugin WITHOUT having to network activate it– I.E. just use it on a child site |
No description provided.
The text was updated successfully, but these errors were encountered: