新的API路由在nginx服务器上给出404,为什么?

时间:2019-06-19 10:39:59

标签: laravel nginx routes

我今天刚刚部署了带有一些新API路由的网站的新版本,由于某些原因,它们在服务器上不起作用。当地一切都很好。我确实清除了服务器上的路由缓存,并出现在路由列表中,但是仍然没有运气...我想知道我的NGINX conf有什么问题吗?

routes / api.php:

/*These two routes are not working on the server...*/
Route::get('locations/{params?}', 'API\HealthCareServicesController@getAllLocations');
Route::get('location/{id}/{params?}', 'API\HealthCareServicesController@getLocation');


Route::group(['middleware' => 'client'], function(){

    Route::get('content', 'API\ContentController@index');
    Route::get('content/menu', 'API\ContentController@menu');
    Route::get('content/menu/children/{parent_id?}', 'API\ContentController@children');

    Route::get('content/page/{id}', 'API\PageController@show');

    Route::post('pushtoken/set', 'API\UserController@createPushToken');
    Route::post('pushtoken/destroy', 'API\UserController@destroyPushToken');
});

NGINX conf:

server {
server_name 52.169.254.60 app.regionhalland.se;
access_log /var/www/appadmin/shared/storage/logs/access.log;
error_log /var/www/appadmin/shared/storage/logs/error.log;
root /var/www/appadmin/current/public;
index index.php index.html;

# serve static files directly
location ~* \.(jpg|jpeg|gif|css|png|js|ico|html|svg)$ {
    access_log off;
    expires max;
    log_not_found off;
}

# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename) {
    rewrite ^/(.+)/$ /$1 permanent;
}

# enforce NO www
if ($host ~* ^www\.(.*)) {
    set $host_without_www $1;
    rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
}

# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename) {
    rewrite ^/(.*)$ /index.php?/$1 last;
    break;
}

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location ~* \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock; # may also be: 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}

location ~ /\.ht {
    deny all;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/app.regionhalland.se/fullchain.pem; # 
managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/app.regionhalland.se/privkey.pem; # 
managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
if ($host = app.regionhalland.se) {
    return 301 https://$host$request_uri;
} # managed by Certbot


server_name 52.169.254.60 app.regionhalland.se;
listen 80;
return 404; # managed by Certbot


}

0 个答案:

没有答案