2

I have a Node JS appengine app. but i want to route anything /blog/* to a separate wordpress VM created through the cloud launcher. it's not an appengine service, just a compute engine VM.

How can I do this?

Current app.yaml:

runtime: nodejs
env: flex

manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

handlers:
- url: /.*
  script: auto
  secure: always
  redirect_http_response_code: 301
Maxim
  • 4,075
  • 1
  • 14
  • 23
CodeOverload
  • 47,274
  • 54
  • 131
  • 219

2 Answers2

1

App.yaml doesn't support redirects to the other resources. This is documentation for handlers section of app.yaml file.

The handlers element is a required element in the app.yaml configuration file. The element provides a list of URL patterns and descriptions of how they should be handled. App Engine can handle URLs by executing application code, or by serving static files uploaded with the code, such as images, CSS, or JavaScript.

So you need to redirect on the different level: I think that the redirect on code level is the best way, but you can try to configure redirection on Google Load Balancing level.

Roman Patutin
  • 2,171
  • 4
  • 23
  • 27
  • I tried to do that, but i can't seem to create an instance zone for an app engine service.. – CodeOverload Aug 28 '18 at 14:55
  • Why do you need a fixed zone for service? – Roman Patutin Aug 29 '18 at 06:40
  • I would use a load balancer with path based routing. However, App Engine is usually deployed for cost reasons (inexpensive). Load balancers will increase the cost. Another consideration is to use Compute Engine, WordPress, add reverse proxy to Apache and move the node app to Compute Engine. Now everything is on one system. – John Hanley Dec 04 '18 at 19:30
1

App Engine app.yaml and dispatch.yaml only redirect to app engine modules/versions. However, you can easily setup a code redirect with something like window.location.replace or window.location.href.

Ying Li
  • 2,500
  • 2
  • 13
  • 37
  • To add to Ying Li's answer, you can also send a Redirect header from your node app to send the client to your external URL. – John Hanley Dec 04 '18 at 19:25