Handler configurations - google-cloud-platform

I need to forward URLs, but the handlers in my app.yaml file are not accepting any configuration:
handlers:
- url: "/dashboard/([a-z])"
script: /admin/index.php?page=\1&token=xxx
- url: "/dashboard/login"
script: /admin/login.php?token=xxx
It only works if you access the full URL.
What's wrong?

Related

AWS Lambda Functions and AWS API Gateway(custom domain name) path redundancy/conflict

I am trying to remove the redundant path which is used in both my serverless configuration and aws api gateway mapping.
Problem:
Login serverless yaml
serverless.yml
frameworkversion: '>1.8'
service: ${stage}-login
provider:
name: aws
runtime: nodejs10.x
timeout: 12
functions:
login:
name: login
handler: login.handler
events:
- http:
path: login
cors: true
integration: lambda
request:
passThrough: WHEN_NO_MATCH
template:
application/json:
<response omitted>
plugins:
- serverless-offline
API mapping to my custom domain
API - login-dev
Stage - dev
Path(optional) - login
Goal:
Lambda Functions :
login - {base url}/dev/login
register - {base url}/dev/register
What happened:
login {base url}/dev/login/login
register - {base url}/dev/register/register
Actions taken:
Tried to remove the Path(optional) but it would not allow me to add another lambda function if path is omitted.
Tried to proxy(unsure if this works the way i understand it) but it doesn;t allow because an error shows that {login} is used in one of my lambda function parameters.
Removed path in serverless yaml configuration file and replaced it with blank or / - but not an option for me because i need to keep the existing configuration.
Any help is very much appreciated.
Have you tried this:
functions:
login:
name: login
handler: login.handler
events:
- http:
path: /login
................
By adding a "/" in the starting of path.

Config React BrowserRouter in Google Cloud Engine

I am using Google Cloud Platform's PHP based static server. My public folder contains one landing page and and a web-app.
The landing page just is a static html file with few css and image files which resides on root.
The web-app is made of React, it's index.html resides inside the folder named app
I have configured my react app to use BrowserRouter.
The web-app returns 404 error when I refresh any page inside the app.
How to configure app.yaml to solve this. My current configuration is below:
runtime: php55
api_version: 1
threadsafe: true
skip_files:
- src/
- node_modules/
- ^(.*/)?app\.yaml
- ^(.*/)?gitlab\.yml
- ^(.*/)?app\.yaml
- ^package\.json
- ^package-lock\.json
- ^README\.md
- ^webpack.config\.js
- ^(.*/)?#.*#
- ^(.*/)?.*~
- ^(.*/)?.*\.py[co]
- ^(.*/)?.*/RCS/.*
- ^(.*/)?\..*
handlers:
- url: /
static_files: public/index.html
upload: public/index.html
secure: always
- url: /app/(.*\.(html|js|css))$
static_files: public/app/\1
upload: public/app/.*\.(html|js|css)$
secure: always
- url: /(.*)
static_files: public/\1
upload: public/(.*)
secure: always
I want to achieve something like nginx server's try_files option.

404 Using Cron Jobs on App Engine

So I am getting this when I try to deploy my app. Here are the files that make up my app:
main.py:
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write("<h1>Duracron!</h1>")
class EventHandler(webapp2.RequestHandler):
def get(self):
self.response.write("<h1>Duracsron!</h1>")
app = webapp2.WSGIApplication([
('/', MainHandler),
('/event/.*', EventHandler),
], debug=True)
app.yaml:
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /.*
script: main.app
libraries:
- name: webapp2
version: "2.5.2"
- name: ssl
version: latest
cron.yaml:
cron:
- description: test task
url: /events/test
schedule: every 1 minutes
I can't seem to find out what's going wrong. From my understanding, the cron.yaml will make a request to the /events/test and app.yaml will redirect it to main.app and main.app routes it to EventsHandler(). What am I missing?
It looks like a typo in the word event which doesn't match events and that may be the cause of the problem. Try changing ('/event/.*', EventHandler), to ('/events/.*', EventHandler), so that it matches your cron.yaml

App engine app.yaml setting for admin users

I was wondering how you can configure your app to restrict certain endpoints to logged in users or even admin users.
Here is my app.yaml
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.app
- url: /admin/.*
script: main.app
login: admin
However this doesn't work. When visiting any endpoint beginning with /admin/ I can simply access the url without logging in. Is there any configuration setting that I'm missing?

Have yaml redirect "/hello/" to "/hello"

Atm, when trying to access
www.eyalw.com/1keyboard/
you get nothing,
but when accessing
www.eyalw.com/1keyboard
you get the correct page.
this is the current yaml:
application: eyalwcom
version: 1
runtime: python27
api_version: 1
threadsafe: no
handlers:
- url: /
static_files: static/index.html
upload: static/index.html
- url: /1keyboard
static_files: static/1keyboard.html
upload: static/1keyboard.html
- url: /
static_dir: static
libraries:
- name: webapp2
version: "2.5.2"
You can put in a regexp to match your url.
I'm not certain I can get the right regexp off the top of my head, I think it would be:
- url: /1keyboard/?
If you would like a trailing slash to always be added you can use a RedirectRoute from webapp2 with strict_slash=True, as described here: http://webapp-improved.appspot.com/api/webapp2_extras/routes.html#webapp2_extras.routes.RedirectRoute1
Instead of adding this to your app.yaml file you would include this where you defined the other routes and linked them to handlers.