404 on live Google App Engine, while working on local SDK server

心已入冬 提交于 2019-12-25 00:34:57

问题


I have deployed several PHP apps on GAE standard environment, all working fine.

Now I'm deploying a new app, which on the local server provided by the gcloud SDK works as expected (terminal command: dev_appserver.py --log_level=warning app.yaml).

The problem is that when I deploy it to the live GAE service (gcloud app deploy app.yaml --project myapp), I get a 404 error message:

The page could not be found

No web page found for the web address: xxx
HTTP ERROR 404

The app.yaml looks like this:

runtime: php55
api_version: 1
threadsafe: true

skip_files:
- README.md
- package.json

handlers:

- url: /(.*\.html)
  script: mod_rewrite.php
  secure: always

- url: /(.*\..{2,})
  static_files: \1
  upload: (.*\..{2,})
  secure: always

- url: /.*
  script: mod_rewrite.php
  secure: always

I'va also tried to add a test handler pointing to a specific file:

- url: /(mytest\.html)
  static_files: \1
  upload: mytest.html
  secure: always

In this way I was able to reach the url. But that was it. Any other url is 404.

An interesting thing is that on the Versions tab of the GAE app in the current deployed version it states that the app is 0 B, even if there are no previous versions of it, while it should be around 30 Mb. When deploying, all 988 files seems to be uploaded, also because due to my slow internet connection it takes a while.

I have tried to redeploy the whole thing to a new project, after successfully completing the tutorial, and I still encounter the same problem.


回答1:


You can use the application_readable handler option to include the respective static files in the app code as well. From Handlers element:

application_readable

Optional. Boolean. By default, files declared in static file handlers are uploaded as static data and are only served to end users. They cannot be read by an application. If this field is set to true, the files are also uploaded as code data so your application can read them. Both uploads are charged against your code and static data storage resource quotas.

Like this:

- url: /(.*\..{2,})
  static_files: \1
  upload: (.*\..{2,})
  application_readable: true
  secure: always



回答2:


After several hours of testing, I finally realized what the problem was.

In GAE when declaring a certain path static, it is then interpreted as a non-code path. All files within that path are therefore not accessible by the scripts running on the PHP environment with require or include and they are not shown in the deployed code debugger.

For this reason, I have placed all static files in a sub-folder (www), and non static files to be required by PHP scripts under another subfolder.



来源:https://stackoverflow.com/questions/46682404/404-on-live-google-app-engine-while-working-on-local-sdk-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!