Elastic Beanstalk amazon linux 2 and Nginx "/var/www/html/webroot" existence failed 2" - amazon-elastic-beanstalk

I got this error from Nginx after deploying the code to AWS EB. The weird thing it is that I can access by ssh to the EC2 instance and the folder and file both EXISTS /var/www/html/webroot/index.php
2022/11/01 15:45:10 [error] 1456#1456: *36 testing "/var/www/html/webroot" existence failed (2: No such file or directory) while logging request, client: 0x2.21.03.15, server: , request: "GET / HTTP/1.1", host: "0x2.21.03.1"
2022/11/01 15:45:20 [error] 1456#1456: *37 "/var/www/html/webroot/index.php" is not found (2: No such file or directory), client: 0x2.21.03.1, server: , request: "GET / HTTP/1.1", host: "0x2.21.03.1"
UPDATE: I fixed the other error by removing a bespoke Nginx.conf file I was pushing with each deployment, but now I am getting this error:
2022/11/01 12:42:28 [error] 13146#13146: *25 open() "/var/www/html/webroot/.git/config" failed (2: No such file or directory), client: 142.xx.xx.1, server: , request: "GET /.git/config HTTP/1.1", host: "3.xx.xx3.x5"
I do not understand why and where EB is checking for a /.git/config file. I have the same code in a different instance type (t3.micro) and it works fine. I never had these issues before, it starts happening when I created a new environment with an instance type "t4g.micro"
Any ideas?
note: Both environments works with Amazon Linux 2 and Nginx server.

Related

AWS Elastic Beanstalk Notification - Environment health has transitioned from Ok to Warning

I keep getting the following messages. But there is nothing in my nginx logs which indicates that requests were returned with status 5xx. Also, app seems to working as expected. Any pointers why I might be getting these?
Message:
Environment health has transitioned from Ok to Warning. 50.0 % of the requests are failing with HTTP 5xx. Insufficient request rate (12.0 requests/min) to determine application health. 1 out of 2 instances are impacted. See instance health for details.
eb logs show the following events around the same time. And they look like a hack attempt. My guess is that these POST requests failure are making EB think that instances are unhealthy. Any advise, how can we prevent this ? Thanks.
2019/02/10 23:49:37 [error] 3263#0: *23308 upstream prematurely closed connection while reading response header from upstream, client: 172.31.35.221, server: , request: "POST /51314.php HTTP/1.1", upstream: "http://172.17.0.2:80/51314.php", host: "xxx.xxx.xxx.xxx"
2019/02/10 23:49:37 [error] 3263#0: *23308 upstream prematurely closed connection while reading response header from upstream, client: 172.31.35.221, server: , request: "POST /fusheng.php HTTP/1.1", upstream: "http://172.17.0.2:80/fusheng.php", host: "xxx.xxx.xxx.xxx"
2019/02/10 23:49:38 [error] 3263#0: *23308 upstream prematurely closed connection while reading response header from upstream, client: 172.31.35.221, server: , request: "POST /repeat.php HTTP/1.1", upstream: "http://172.17.0.2:80/repeat.php", host: "xxx.xxx.xxx.xxx"
2019/02/10 23:49:39 [error] 3263#0: *23308 upstream prematurely closed connection while reading response header from upstream, client: 172.31.35.221, server: , request: "POST /api.php HTTP/1.1", upstream: "http://172.17.0.2:80/api.php", host: "xxx.xxx.xxx.xxx"
2019/02/10 23:49:40 [error] 3263#0: *23308 upstream prematurely closed connection while reading response header from upstream, client: 172.31.35.221, server: , request: "POST /xiaodai.php HTTP/1.1", upstream: "http://172.17.0.2:80/xiaodai.php", host: "xxx.xxx.xxx.xxx"
2019/02/10 23:49:40 [error] 3263#0: *23308 upstream prematurely closed connection while reading response header from upstream, client: 172.31.35.221, server: , request: "POST /xiaodai.php HTTP/1.1", upstream: "http://172.17.0.2:80/xiaodai.php", host: "xxx.xxx.xxx.xxx"
Thanks.
Example reasons can be
nginx proxy crashed on the instance
high CPU usage on the instance
high memory usage on the instance
deployment failure on the instance

NGINX crashes with 404 not found error

I have ubuntu 14.04 and on the server I have nginx & mysql.
Everything works fine but after 5-10 requests to the API the nginx crashes.
The site has been loading for a long time ends up with 404 not found error.
When I restart the service service nginx restart my site is up again.
I have a strong server with
64GB Ram, 1Gbit Port 33TBMonth,
1TB Disk. 12Cores 24Threads.
I don't understand what's the error and how to solve it.
This is the nginx.conf:
https://pastebin.com/raw/eQtMSKAY
error log nginx:
2017/07/30 06:55:43 [error] 18441#0: *6302 connect()
to unix:/var/run/php5-fpm.sock failed (11: Resource
temporarily unavailable) while connecting to upstream,
client: XX.XX.XX.XX, server: 4107.150.4.82, request:
"GET /panel/ajax/user/tools/server?method=getstatus&port=25565 HTTP/1.1",
upstream: "fastcgi://unix:/var/run/php5-fpm.sock:",
host: "pay2play.co.il", referrer:
"http://pay2play.co.il/panel/panel?id=15"
2017/07/30 06:55:43 [error] 18441#0: *6302 open()
"/usr/share/nginx/html/50x.html" failed (2: No such file
or directory), client: 5.29.8.30, server: 107.150.44.82,
request: "GET /panel/ajax/user/tools/server?method=getstatus&port=25565 HTTP/1.1",
upstream: "fastcgi://unix:/var/run/php5-fpm.sock",
host: "pay2play.co.il", referrer:
"http://pay2play.co.il/panel/panel?id=15"
Based on what you pasted, the actual error is on the PHP side. The 404 is just nginx attempting to render a "nice" error page for the 503/4, contained in 50x.html. While your pasted version doesn't include it, it's likely contained in one of the includes (which are more relevant to the question than the top-level configuration shown here).
I expect there is something like (from the nginx docs actually):
error_page 500 502 503 504 /50x.html;

Symfony2 with Ngix Bad gateway on hold f5

When I pressed f5 button in my webpage (5~ seconds kept, test purpose)
my website displays
"502 bad gateway"
I am using symfony 2.6 and mysql with PHP-fpm my VPS have 1GB RAM and 1 core CPU. the nginx log display:
2015/05/12 12:41:17 [error] 9541#0: *661 connect() to unix:/var/run/php5-fpm.sock failed (11: Resource temporarily unavailable)
while connecting to upstream,
client: 127.0.0.1,
server: localhost,
request: "GET /app_dev.php/ HTTP/1.1",
upstream: "fastcgi://unix:/var/run/php5-fpm.sock:",
host: "localhost"
The connection is lost after the test and return after 30 seconds~
Question: How can I configure Nginx to prevent that? I need that my website don't fall on many http request

502 bad gateway error

When I browse the Magento web site multiple times, I usually get 502 bad gateway error at Nginx.
Please help me on fixing this issue.
Note:- php5-fpm is not running some of the time. After restarting the php5-fpm, everything is working fine but after some time I am getting the same(php5-fpm is not running) error again .
Ngnix Error Logs: -
2014/06/30 12:24:17 [error] 13359#0: *297122 connect() failed (111: Connection refused) while connecting to upstream, client: xxxxxxxx, server: www.xxxxxxxx.com, request: "GET /ultimate-comics-x-men-1967641 HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.xxxxxxxx.com"
2014/06/30 12:24:28 [error] 13359#0: *297124 connect() failed (111: Connection refused) while connecting to upstream, client: xxxxxxxx, server: www.xxxxxxxx.com, request: "GET /virtual-engineering-simulation-and-optimization HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "www.xxxxxxxx.com"

Nginx CodeIgniter not working

I am new to nginx. I am transfering my server from apache to nginx but my many projects on the CodeIgniter core PHP sites working perfectly but the CodeIgniter is not work.
My sample url like this:
http://example.com/track/
this is redirect to:
http://example.com/track/index.php/sessions/login
but it returns 404 Not Found.
my server configure like this:
server {
listen 80;
server_name 192.168.0.80;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
my error log file like this
2013/05/15 10:21:37 [error] 2474#0: *3 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 192.168.0.11, server: 192.168.0.80, request: "GET /favicon.ico HTTP/1.1", host: "192.168.0.80"
2013/05/15 10:21:37 [error] 2474#0: *1 FastCGI sent in stderr: "Unable to open primary script: /usr/share/nginx/html/index.php (No such file or directory)" while reading response header from upstream, client: 192.168.0.11, server: 192.168.0.80, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "192.168.0.80"
2013/05/15 10:22:05 [error] 2474#0: *1 open() "/usr/share/nginx/html/track/index.php/sessions/login" failed (20: Not a directory), client: 192.168.0.11, server: 192.168.0.80, request: "GET /track/index.php/sessions/login HTTP/1.1", host: "192.168.0.80"
2013/05/15 10:26:46 [error] 2474#0: *5 open() "/usr/share/nginx/html/track/index.php/sessions/login" failed (20: Not a directory), client: 192.168.0.11, server: 192.168.0.80, request: "GET /track/index.php/sessions/login HTTP/1.1", host: "192.168.0.80"
2013/05/15 10:28:33 [error] 2474#0: *7 open() "/usr/share/nginx/html/track/index.php/sessions/login" failed (20: Not a directory), client: 192.168.0.11, server: 192.168.0.80, request: "GET /track/index.php/sessions/login HTTP/1.1", host: "192.168.0.80"
2013/05/15 10:29:59 [error] 2497#0: *1 open() "/usr/share/nginx/html/track/index.php/sessions/login" failed (20: Not a directory), client: 192.168.0.11, server: 192.168.0.80, request: "GET /track/index.php/sessions/login HTTP/1.1", host: "192.168.0.80"
What's wrong? I did a search in google but not working perfectly.
Check out this link, should fix your rewriting issues.
If you have further questions you can ask.
Code igniter for nginx
Edit:
Ok so there's several ways to fix your case, but I'll describe the closest to your case
If you're going to edit in the same file as nginx conf as how I think you're doing right now then try adding this
location /track {
try_files $uri $uri/ /track/index.php;
}
Not sure if the routing needs $request_uri appended to index.php or not.
And i think you should configure CodeIgniter to be aware of this sub folder
$config['base_url'] = "192.168.0.80/track"
This isn't really the cleanest way to do this configuration, I'd prefer adding a domain name in the /etc/hosts and create a new separate server in nginx.
I ran into a similar problem earlier today: the code igniter URI routing requires that both the REQUEST_URI and the SCRIPT_NAME variables be defined. Many of the Nginx/PHP-FPM guides don't define the SCRIPT_NAME variable, so you end up with routing failures. You'll need to add a line that looks like this:
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
and then you can use REQUEST_URI in your config.php file and the routing should work.