I have a site with Ubuntu 20.04, php 8.1, and nginx 1.23.1. If I restart nginx and php-fpm I can login, browse the site, and everything works. If I wait a certain amount of time with no activity on the site (10-15 minutes?), I start getting 302 Found errors no matter what page I try to go to. If I restart nginx and php-fpm again, everything starts working again. I can't figure out what's causing this. Here is the nginx config file for the site:
server {
listen 1443 ssl;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains" ;
server_name my_site;
root /var/www/my_site/htdocs;
index index.php index.html;
access_log /var/log/nginx/my_site.access.log;
error_log /var/log/nginx/my_site.error.log;
ssl_certificate /etc/nginx/ssl/all.my_site.com.crt;
ssl_certificate_key /etc/nginx/ssl/all.my_site.com.key;
ssl_session_timeout 5m;
ssl_session_cache shared:SSL:50m;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK';
ssl_prefer_server_ciphers on;
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
location / {
try_files $uri =404;
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param ALL_FILES_PATH /var/www/my_site;
fastcgi_param LOCAL_FILES_PATH /var/www/my_site;
fastcgi_param SHARED_FILES_PATH /var/www/my_site-web-8.1;
fastcgi_read_timeout 604800;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
}
EDIT: It appears that this 302 error is only happening with PHP files. I put a basic html file in and it loads with a 200 response code.