简体   繁体   English

Luracast \\ Restler:未找到NGINX 404

[英]Luracast\Restler: NGINX 404 not found

I'm trying to install luracast restler on nginx + php7.1 but I always get the following output. 我正在尝试在nginx + php7.1上安装luracast restler,但我总是得到以下输出。 (On localhost with apache + php 7.1 everything works fine) (在apache + php 7.1的localhost上,一切正常

 { "error": { "code": 404, "message": "Not Found" }, "debug": { "source": "Routes.php:431 at route stage", "stages": { "success": [ "get" ], "failure": [ "route", "negotiate", "message" ] } } } 

When I try resources.json I get this: 当我尝试resources.json时,我得到了:

 { "apiVersion": "1", "swaggerVersion": "1.1", "basePath": "https://api.example.com/api", "produces": [ "application/json" ], "consumes": [ "application/json" ], "apis": [] } 

NGINX.conf: NGINX.conf:

 server { listen *:443 ssl http2; server_name api.example.com; keepalive_timeout 70; root /var/www/public; # Security add_header Strict-Transport-Security "max-age=31536000; includeSubdomains" always; add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; fastcgi_param HTTPS on; location /api/ { try_files $uri $uri/ /api/index.php$is_args$args; } location ~ \\.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi.conf; } location ~ \\.(aspx|jsp|cgi)$ { return 410; } location ~ /\\.ht { deny all; } ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; ssl_prefer_server_ciphers on; ssl_certificate /etc/letsencrypt/live/api.example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/api.example.com/privkey.pem; } 

index.php: index.php:

 <?php require_once 'vendor/restler.php'; use Luracast\\Restler\\Restler; use Luracast\\Restler\\Defaults; Luracast\\Restler\\Resources::$hideProtected = false; Defaults::$crossOriginResourceSharing = true; Defaults::$accessControlAllowOrigin = '*'; Defaults::$accessControlAllowMethods = 'GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD'; $r = new Restler(); $r->addAPIClass('Resources'); $r->addAPIClass('Explorer'); $r->addAPIClass('Controller\\User'); $r->addAPIClass('Controller\\Place'); $r->addAPIClass('Controller\\Event'); $r->addAPIClass('Controller\\Post'); $r->addAPIClass('Controller\\Login'); $r->addAPIClass('Controller\\Register'); $r->addAuthenticationClass('Controller\\AccessControl'); $r->handle(); 

On localhost with apache all works fine and I get the following output: 在使用apache的localhost上,一切正常,我得到以下输出:

 { "apiVersion": "1", "swaggerVersion": "1.1", "basePath": "http://localhost/api", "produces": [ "application/json" ], "consumes": [ "application/json" ], "apis": [ { "path": "/resources/user.{format}", "description": "Class User" }, { "path": "/resources/place.{format}", "description": "Class Place" }, { "path": "/resources/event.{format}", "description": "Class Event" }, { "path": "/resources/post.{format}", "description": "Class Post" }, { "path": "/resources/login.{format}", "description": "Class Login" }, { "path": "/resources/register.{format}", "description": "Class Register" } ] } 

I also tried composer update to update the generated autoload routes. 我还尝试了作曲家更新来更新生成的自动加载路线。 But doesn't work. 但是不起作用。 Does anyone have an answer? 有人有答案吗?

Best regards 最好的祝福

Restler is working fine, that's why you get JSON output :) Restler运行正常,这就是为什么您得到JSON输出的原因:)

But your classes does not seem to load. 但是您的课程似乎没有加载。

Try to include them manually and see if it fixes the issue! 尝试手动包括它们,看看是否可以解决问题!

Then you can try /user/{id} and see if it works! 然后,您可以尝试/user/{id}看看是否可行!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM