在生产中,当我在浏览器中导航到http://api.mywebsite.com/api/mail/send时,即使定义了路由并且“我认为”我的nginx配置正确,也找不到404页面。也许有人可以发现我的问题?
在api.php中,我有这个:Route :: get('/ api / mail / send','MailController @ index');
然后在我的/etc/nginx/sites-enabled/mywebsite.com中定义以下内容:
server {
listen 80;
server_name mywebsite.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
add_header Access-Control-Allow-Origin mywebsite.com;
}
server {
listen 80;
server_name api.mywebsite.com;
add_header Access-Control-Allow-Origin mywebsite.com;
root /mywebsite/api/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php = 404;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
第二个服务器块用于我想在子域中显示的laravel api。 我的配置有什么问题吗?