I have an ec2 instance running nginx.
Here is my nginx config:
server {
listen 443 ssl;
root /var/www/angular/dist/testenpoint-website-angular;
index index.htm index.html;
server_name www.testenpoint.com;
client_max_body_size 100m;
location / {
try_files $uri $uri/ /index.html;
}
location /applicationApis/ {
root /var/www/html;
try_files $uri $uri/ =404;
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm/www.sock;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
ssl_certificate /etc/letsencrypt/live/testenpoint-all/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/testenpoint-all/privkey.pem; # managed by Certbot
}
server {
if ($host = testenpoint.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = www.testenpoint.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80; #listen for all the HTTP requests
server_name testenpoint.com www.testenpoint.com;
return 301 https://www.testenpoint.com$request_uri;
}
server {
if ($host = testenpoint.co.uk) {
return 301 https://www.testenpoint.com$request_uri;
} # managed by Certbot
if ($host = www.testenpoint.co.uk) {
return 301 https://www.testenpoint.com$request_uri;
} # managed by Certbot
listen 80;
server_name testenpoint.co.uk *.testenpoint.co.uk;
return 301 https://www.testenpoint.com$request_uri;
}
server {
listen 443;
server_name testenpoint.co.uk *.testenpoint.co.uk;
return 301 https://www.testenpoint.com$request_uri;
}
I am calling this via my angular application like so:
https://www.testenpoint.com/applicationApis/getPdfReport.php
With the request is send auth header and in the body a few params. One param is called 'filterObject' this is a string object. When this is empty the request is fine. When I send stuff in there via my angular application I have a 404 response. Via postman, no issues. Via my test instance no issues.
This error appears in my nginx logs when this happens:
2023/01/03 19:28:50 [error] 24875#0: *42 upstream sent too big header while reading response header from upstream, client: xx.xx.xxx.xxx, server: www.testenpoint.com, request: "POST /applicationApis/getPdfReport.php HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock:", host: "www.testenpoint.com", referrer: "http://localhost:4200/"
and
2023/01/03 19:28:50 [error] 24875#0: *42 open() "/var/www/angular/dist/my-website-angular/50x.html" failed (2: No such file or directory), client: xx.xx.xx.xx, server: www.testenpoint.com, request: "POST /applicationApis/getPdfReport.php HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/www.sock", host: "www.testenpoint.com", referrer: "http://localhost:4200/"
I am wondering if anyone can help here?
Also to note the the PHP code actually runs as I can see the logs etc all the way to completion. But all I get is a 404 even though my PHP code is showing no error. I believe it is an Nginx config issue and its only happening on this instance with this config and not my test instance with a slightly different config