0

I'm struggling to setup URL handlers in the handlers section of my app.yaml file for my standard engine php application.

Following code makes both mydomain.com/abc.php and mydomain.com display the abc.php file in my dist folder:

handlers:
- url: /(abc\.php)
  script: dist/abc.php

- url: /(.*)
  script: dist/abc.php

However, I don't want a catch all handler, so I removed it so only 1 handler exists:

handlers:
- url: /(abc\.php)
  script: dist/abc.php

Now when I go to mydomain.com/abc.php, I'm getting a 500 error:

500 error

How can I make a targeted URL work on GAE without using a handler for all URL's?

Community
  • 1
  • 1
Adriaan Meuris
  • 351
  • 2
  • 12
  • 1
    What is the error you see in your logs? – new name Mar 09 '18 at 13:26
  • I had a look at the StackDriver Logging but I can only see requests to /_ah/start + some createVersion logs - no specifics on the php error. Any advise on how I can see PHP errors? – Adriaan Meuris Mar 10 '18 at 15:47
  • From [the docs](https://cloud.google.com/appengine/docs/standard/python/config/appref#handlers_element) it says that the _patterns are evaluated from top to bottom_. You initially had URL pattern A, and URL pattern B. When having only A, it is not working. I would say that your requests were handled through pattern B; A failed and they moved on to B. I am not sure yet why... appart from the previous docs, you lack the `$`, the [end anchor](https://www.regular-expressions.info/anchors.html#aswift_1_anchor) – Tudormi Mar 14 '18 at 16:08
  • I've created 2 separate projects to make sure old handlers weren't reused/cached, so I don't think that's the issue. I've setup a 3rd project following your suggestion: `handlers:` `- url: /abc.php$` `script: dist/abc.php` this also results in the same 500 error as before. – Adriaan Meuris Mar 18 '18 at 09:43
  • I took the [simplest code](https://github.com/GoogleCloudPlatform/appengine-php-guestbook/tree/phase0-helloworld) and reproduced your handlers. And it works. Moreover, I get 404s (not 5XXs) when I hit bad URLs, if I don't have a catch all handler. A difference I can think about is the custom domain, which I lack. Also, regarding logs, you should be able to see both `activity` and `request_log`. If no requests are logged, it means that the requests are not resolved and directed towards your app. Try w/o the custom domain, to eliminate one factor. – Tudormi Mar 19 '18 at 09:33
  • I used the same helloworld example, and I'm using it without a custom domain. If you'd like more information about the exact setup, check out the issue in the GAE issue tracker: https://issuetracker.google.com/issues/74469001 – Adriaan Meuris Mar 20 '18 at 10:51
  • thanks for sharing the issue tracker link. If you get a solution via that channel I kindly ask you to provide a response here as well. – Tudormi Mar 21 '18 at 14:50

1 Answers1

1

My app.yaml file contained resources:

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

Since this isn't supported by the App Engine Standard environment, simply commenting out this code resolved the issue.

Adriaan Meuris
  • 351
  • 2
  • 12