任何获得404 Not Found的AWS EB Laravel路由nginx/1.16.1 [英] Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1
问题描述
我刚刚在AWS Elastic beantalk上部署了一个新的laravel 7应用程序.我注意到他们将Apache服务器更改为Nginx服务器.
I've just deploy a new laravel 7 application on AWS Elastic beanstalk. I've noticed they changed the Apache server to Nginx server.
https://docs.aws.amazon. com/elasticbeanstalk/latest/platforms/platform-history-php.html
这是我的api后端URL: http://mappab-api-staging.mappab. com.br/
This is my api backend URL: http://mappab-api-staging.mappab.com.br/
这是登录路径: http://mappab-api-staging.mappab. com.br/login -404状态.
This is the login route: http://mappab-api-staging.mappab.com.br/login - 404 status.
您遇到同样的问题吗?我该如何解决?
Did you get the same problem? How can I fix it?
我位于/etc/nginx/conf.d/elasticbeanstalk/的php.conf是:
My php.conf placed at /etc/nginx/conf.d/elasticbeanstalk/ is:
root /var/www/html/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ /\.ht {
deny all;
}
location ~ /.well-known {
allow all;
}
location ~ \.(php|phar)(/.*)?$ {
fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$;
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass php-fpm;
}
推荐答案
如果您将Amazon linux 2与带有Elastic Beanstalk的Nginx服务器一起使用,则需要遵循
If you are using Amazon linux 2 with elastic beanstalk with an nginx server then you need to follow the guidance here https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html
尽管所有您需要做的就是创建一个文件夹结构,该文件夹结构映射了要放置配置文件的nginx配置位置,并将.platform作为最顶层的文件夹 这应该在您的应用程序根目录中
Simply though all you need to do is create a folder structure mapping the nginx config location you want to place you config file with .platform as the topmost folder this should be in your application root
即在laravel应用中,在与应用文件夹相同的级别上创建一个名为.platform的文件夹 在此.platform文件夹中,创建以下/nginx/conf.d/elasticbeanstalk 所以你有一个文件夹结构,如.platform/nginx/conf.d/elasticbeanstalk 在最后一个文件夹elasticbeanstalk中,将您的配置文件
i.e. in a laravel app create a folder called .platform in the same level as the app folder within this .platform folder create the following /nginx/conf.d/elasticbeanstalk so you have a folder structure like .platform/nginx/conf.d/elasticbeanstalk in this last folder elasticbeanstalk place your config file
例如 laravel.conf
e.g. laravel.conf
location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}
将应用程序上载到eb之后,它将文件复制到服务器上的相同位置并重新启动nginx 希望有道理
once you upload the application to eb it will copy the file to the same location on the server and restart nginx Hope that makes sense
这篇关于任何获得404 Not Found的AWS EB Laravel路由nginx/1.16.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!