Google App Engine modules: routing second module to subdirectory - wordpress

Has anyone run two different WordPress installations as separate modules inside Google App Engine?
I have the following:
/app/
- wordpress1
- wordpress2
- app.yaml
- second.yaml
- dispatch.yaml
- php.ini
Inside wordpress1 and wordpress2 are somewhat clean installations of WordPress, with some GAE helper plugins.
app.yaml contains the default module config, which redirects traffic to wordpress1 using URL handlers.
second.yaml contains the second module config (module: second) and redirects traffic to wordpress2.
In dispatch.yaml I only check for a subdir second to load the second.yaml config:
dispatch:
- url: "*/second*"
module: second
Everything is fine and dandy:
http://localhost.dev:8080 -> wordpress1/index.php
http://localhost.dev:8080/second/ -> wordpress2/index.php
But I can't seem to work out how to set the edge cases:
http://localhost.dev:8080/secondwithextra -> dispatcher error (no URL set)
http://localhost.dev:8080/second (missing trailing slash) -> same as above
I tried to add the following to second.yaml handlers:
- url: /second[^/].+/?
script: wordpress1/index.php # Reroute to `wordpress1` because not a directory match.
But that didn't really work out.
How can I make the second module accept request URI /second, /second/, /second/abc but not /secondxyz?
Having the dispatch.yaml URL glob set to */second/* breaks the slashless /second.

I think you could try to add both */second/* and /second in dispatch.yaml.

Related

Google App Engine Flex: Wordpress Plugin's Read/Write File Permissions

We are trying to see if Google App Engine will be a good fit for our Wordpress Sites. I just ran into an issue with a plugin that needs to have a folder with read/write/execute permissions.
"All in One WP Migration is not able to create /app/wordpress/wp-content/plugins/all-in-one-wp-migration/storage folder. You will need to create this folder and grant it read/write/execute permissions (0777) for the All in One WP Migration plugin to function properly."
I noticed in order to upload media files, you need to activate the Google Cloud Storage plugin. So this takes care of that issue, but how should I handle plugins and other I/O?
I thought using Flex instead of Standard would fix this.
App.yaml
runtime: php
env: flex
beta_settings:
cloud_sql_instances: my-project:us-east4:test-instance
runtime_config:
document_root: wordpress
env_variables:
WHITELIST_FUNCTIONS: escapeshellarg,escapeshellcmd,exec,pclose,popen,shell_exec,phpversion,php_uname
php.ini
extension=bcmath.so
extension=gd.so
zend_extension=opcache.so
short_open_tag=On
google_app_engine.disable_readonly_filesystem = 1
EDIT:
I found something to put in app.yaml HOWEVER I don't know if this should be something on production
In the runtime_config I added
skip_lockdown_document_root: true
I'd like to know if this acceptable to put on a live site.
I also put:
handlers:
- url: /(.*\.(htm|html|css|js))$
static_files: wordpress/\1
upload: wordpress/.*\.(htm|html|css|js)$
application_readable: true
- url: /wp-content/(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
static_files: wordpress/wp-content/\1
upload: wordpress/wp-content/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
application_readable: true
- url: /(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
static_files: wordpress/\1
upload: wordpress/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
application_readable: true
- url: /wp-includes/images/media/(.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg))$
static_files: wordpress/wp-includes/images/media/\1
upload: wordpress/wp-includes/images/media/.*\.(ico|jpg|jpeg|png|gif|woff|ttf|otf|eot|svg)$
application_readable: true
- url: /wp-admin/(.+)
script: wordpress/wp-admin/\1
secure: always
- url: /wp-admin/
script: wordpress/wp-admin/index.php
secure: always
- url: /wp-login.php
script: wordpress/wp-login.php
secure: always
- url: /wp-cron.php
script: wordpress/wp-cron.php
login: admin
- url: /xmlrpc.php
script: wordpress/xmlrpc.php
- url: /wp-(.+).php
script: wordpress/wp-\1.php
- url: /(.+)?/?
script: wordpress/index.php
If you want to use standard, there's the limitation that GAE apps can't write to the filesystem.
If the plugin requires to write to the filesystem, then you should use flex.
Even when using flex, whatever is written in the filesystem will not be persisted as the only current storage option is to create a ramdisk in the instance, but the data stored there is not shared among instances, and will be lost on instance death.
There seems to be some workaround to use GCSfuse to mount a somewhat persistent storage in GAE flex, but I would not suggest it as you would run into concurrent write issues.
To summarize, if you need to read and write data into a persistent storage shared between all the instances, GAE is not the solution for you. After all, the whole point of serverless is the idempotence of executions. If your app depends on locally stored files (as this Wordpress plugin seems to do), then the result of the execution will depend on what instance is handling the request.

Codeception WebDriver url remove trailing slash

I'm trying to test Laravel 5.3 application. To bootstrap an application with testing config I have added index-testing.php entry point.
I have my codeception acceptance test config like this:
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'http://nginx/index-testing.php'
host: 'selenium'
browser: 'chrome'
- \Helper\Acceptance_selenium
And here is a piece of output of the test scenario:
Scenario --
I am on page "/"
[GET] http://nginx/index-testing.php/
I click ".apply-button"
So instead of http://nginx/index-testing.php it actually goes to http://nginx/index-testing.php/ which of course results in 404
How to I remove this trailing slash?
I found the answer!
In a test I was getting home page like this:
$I->amOnPage('/');
When I changed to this:
$I->amOnPage('');
No more trailing slash present.

PrestaSitemap bundle generates localhost on production server

I'm using Presta SiteMap Bundle for generating sitemaps on my site, but when it generates to me sitemaps on prod server path to sitemaps looks like below:
http://localhost/sitemap.holidayideas.xml
What should I write in config or anywhere in my app to generate correct url's for my sitemaps.
P.S. I'm using Symfony 3.3.2 for my app
I found the solution - need to specify url and protocol in parameters.yml as below:
# app/config/parameters.yml
parameters:
router.request_context.host: your-domain.com
router.request_context.scheme: http

Kong refuses to recognise custom plugin as enabled

I was developing a Custom plugin for Kong.
To start off I followed guidelines listed in this tutorial
http://streamdata.io/blog/developing-an-helloworld-kong-plugin/
Few changes that I made along the way were changing dependency in the rockspec file for "lrexlib-pcre" from version 2.8.0-1 to 2.7.2-1 due to compilation problems that I faced with 2.8.0-1 version.
Please note that I am working in the next branch. The master branch has version 2.7.2-1 listed.
The tutorial assumes Kong version 0.4.2-1 while I am working with Kong version 0.5.2-1.
I have listed my plugin in kong.yml. Last listed is helloworld plugin
plugins_available:
- ssl
- jwt
- acl
- cors
- oauth2
- tcp-log
- udp-log
- file-log
- http-log
- key-auth
- hmac-auth
- basic-auth
- ip-restriction
- mashape-analytics
- request-transformer
- response-transformer
- request-size-limiting
- rate-limiting
- response-ratelimiting
- helloworld
I have listed the helloworld files in rockspec file at the last.
["kong.plugins.helloworld.handler"] =
"kong/plugins/helloworld/handler.lua",
["kong.plugins.helloworld.access"] = "kong/plugins/helloworld/access.lua",
["kong.plugins.helloworld.schema"] = "kong/plugins/helloworld/schema.lua"
Compilation is successful but kong refuses to list helloworld plugin as available in the node. All other builtin plugins are shown as available in the server
I tried enabling the plugin anyway with mock api. It doesn't work as expected and trying to restart kong lists error
nginx: [error] [lua] init_by_lua:5: Startup error:
/usr/local/share/lua/5.1/kong.lua:82: You are using a plugin that has
not been enabled in the configuration: helloworld [INFO] dnsmasq
stopped [ERR] Could not start Kong
I know there were some breaking changes introduced in Kong version 0.5. I followed the changelog, but I found nothing that would help.
Am i missing a setting a configuration somewhere?
Any help would be appreciated.
Try the following in your kong.yml:
custom_plugins:
- helloworld
I fixed this issue by adding things in custom_plugins and lua_package_path.
Here are the steps to enable and use custom plugin in kong Env.
1 - Add custom plugin name in --- custom_plugins = hello-world
2 - Install hello-world plugin by using following steps ---
If you have source code of your plugin then move into it and execute the command --- "luarocks make"
it will install your plugin.
now you have to execute a command "make install-dev" make sure your plugin have makefile like as --
Once you execute this command "make install-dev". it will create lua file at a location something like that -
/your-plugin-path/lua_modules/share/lua/5.1/kong/plugins/your-plugin-name/?.lua
just copy this path and add it into the kong configuration file in lua_package_path
Something like that --
lua_package_path=/your-plugin-path/lua_modules/share/lua/5.1/kong/plugins/your-plugin-name/?.lua
Now you done your job.
Just start kong -- kong start --vv
You will see that the plugin loaded into kong plugin env.
#Enjoy

Symfony2 on nginx shared hosting

i've a symfony 2.3.16 project which work great on localhost.
But today i wanted to host it on my remote server : its a shared hosting on nginx 1.4.7
i've changed the public folder (from /web to /public_html : still working great on localhost)
i've cleared then deleted the dev and prod cache,
added my remote IP to app_dev.php and activate the debuger in app.php
and then uploaded all files to my shared hosting.
the tree is like this :
app
bin
public_html
- bundles
- app.php
- app_dev.php
- config.php
- .htaccess
src
vendor
and when i try to access some pages, i've always ended with a 404 Not Found error.
here, you can see : http://dojonantais.cwebh.org/app.php/admin/
i have no route defined for /
my app/config/routing.yml is like this :
dnAdmin:
resource: "#dnAdminBundle/Resources/config/routing.yml"
prefix: /admin
also, when i try dev environnement http://dojonantais.cwebh.org/app_dev.php
it says there is no route for /, which is logic, but i've another error with the debug bar :
An error occurred while loading the web debug toolbar (404: Not Found).
Do you want to open the profiler?
and when i open the profiler : 404 not found
again, i can access the config.php and it says my server is ok to run Symfony, but cant access the configurator (404 error)
So, what is missing?
Thanks again.
So, problems coming from my remote host on nginx.
i change the host to a 1and1 server and all is ok.

Resources