У меня есть сервер (Ubuntu), на котором я развернул Angular 8 и проект Laravel.Laravel для запросов API.Когда я захожу на свой IP-адрес, я вижу угловую работу, маршруты работают и т. Д. Но у меня возникает проблема при вызове моего ipaddress / api / myroute => (users), например.Я думаю, что в моем файле должно быть что-то не так:
server {
listen 80 default_server;
# listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
# Add index.php to the list if you are using PHP
index index.html index.htm index.php;
server_name MY IP ADRESS;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
charset utf-8; ## Set the charset ##
location / { ## ANGULAR(SSR-Node)
root /var/www/html/frontend;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ /index.html;
proxy_pass http://127.0.0.1:4000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /api {
alias /var/www/html/laravel/public; ## Site root for Laravel code ##
try_files $uri $uri/ /index.php?$query_string;
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
# All files that end with .php are through fastcgi
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.(?!well-known).* {
deny all;
}
}
Вот также мой файл route / api.php:
<?php
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
/***** USERS ******/
// List of users
Route::get('users', 'UserController@index');
// List of top users
Route::get('users/best', 'UserController@indexTopUsers');
// Update top users
Route::middleware('jwt.auth')->post('updatetopusers', 'UserController@saveTopUsers');
// Store follower to current signed user
Route::middleware('jwt.auth')->post('users/follower', 'UserController@storeFollower');
// Delete follower to current signed user
Route::middleware('jwt.auth')->post('users/unfollower', 'UserController@unFollower');
// Get single user
Route::get('users/{id}', 'UserController@show');
// Get single user profile avatar
Route::get('public/uploads/avatar/{id}', 'UserController@getUserAvatar');
Route::middleware('jwt.auth')->post('users/upload/{id}', 'UserController@uploadAvatar');
//Create new User- SIGN UP USER!
Route::post('user', 'UserController@store');
// Update User
Route::middleware('jwt.auth')->post('users/edit/{id}', 'UserController@update');
// Delete User
Route::middleware('jwt.auth')->delete('users/delete/{id}', 'UserController@destroy');
//SIGN IN USER
Route::post('user/signin', 'UserController@signInUser');
// Get filtered users
Route::get('users/filter/{id}', 'UserController@showFilteredUsers');
// Get list of users that matches some LIKE char
Route::get('/users/queryusers/{char}', 'UserController@queryUsers');
// Get list of users that matches some LIKE char
Route::get('users/search/{char}/{sort}', 'UserController@queryUsersWithParams');
//POST USER AVATAR
Route::middleware('jwt.auth')->post('users/{id}/avatarupload', 'UserController@uploadAvatar');
// Get current logged user
Route::middleware('jwt.auth')->get('user-current', 'UserController@me');
/***** USERS ******/
Я следовал из laravel web, как установить nginxи использование PHP 7.2.19-0ubuntu0.19.04.2 с комбо Angular 8 (SSR).
Любая помощь будет приветствоваться.