Laravel POST an Nginx verursacht HTTP 400Php

PHP-Programmierer chatten hier
Anonymous
 Laravel POST an Nginx verursacht HTTP 400

Post by Anonymous »

  • Ich verwende Apache für die Entwicklung und Nginx auf einem neuen Produktionsserver, den ich gerade bereitgestellt habe.
  • In meinem Laravel-Projekt gibt es ein Formular (X), das beim POST an Nginx mit Chrome zu HTTP 400 führt. Es sieht nicht wie die typische Laravel-Fehlerseite aus.

    Code: Select all

    Oops! An Error Occurred
    The server returned a "400 Bad Request".
    Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
    
  • Code: Select all

    storage/logs/laravel.log
    ist auch leer, wenn HTTP 400 angezeigt wird, was bestätigt, dass es sich nicht um einen von PHP generierten Fehler handelt.
  • Wenn form login, es gibt HTTP 200 zurück
  • Zusammengenommen ergibt es für mich ein ziemlich verwirrendes Bild
  • Ich habe meine Nginx-Konfiguration, mein Blade und die Anforderungsreproduktion mit Curl mithilfe von Chrome bereitgestellt
  • Ich möchte verstehen, warum dies unter Nginx passiert und welche Optionen ich habe, um korrekt auf beide Servertypen zu posten, da ich nur das Blade steuern kann
Nginx-Konfiguration

Code: Select all

add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";

index index.php;

charset utf-8;

index index.html;

# Security Headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src 'self' http: https: data: blob;" always;

error_page 404 /index.php;

location ~ ^/index\.php(/|$) {
fastcgi_pass unix:/var/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_hide_header X-Powered-By;
}
Blade

Code: Select all

@csrf
Submit

Reproduzieren Sie Nginx HTTP 400 mit Curl (generiert von Chrome)

Code: Select all

curl 'https://example.com' \
-H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7' \
-H 'accept-language: en-US,en;q=0.9' \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-b 'XSRF-TOKEN=eyJpdiI6Ik9lK0JLZWhqWEUrOVR6TWxtYWgyMHc9PSIsInZhbHVlIjoiQys0N0ZNOFpXZGR6SFcyaGk5d0w1LzBDblFNQmF6b045WmV1UjR2Z2xUZFA0RFRFMVhWQjA5Y0M2d2pjRzdNSUFSRzc5cmc5NlhKWUdQUmZoUDI4RDJzbnMvMUhWd0IzNVREbG5XRHVRM1Y2Mm1xY1NwL2V4ckpiV2pKQThyVm8iLCJtYWMiOiI0MWVjM2U2NWI4OTNkZmFlMDkzZDgwNzE2NmVmM2Y4MDI2NGIxMGZjZjc1OTFhZDBmMGY4ZTBiMDk3MmU4NzVjIiwidGFnIjoiIn0%3D; laravel_session=eyJpdiI6ImhYZXhLZHl4K1FEVC9HcVR6OXdwcmc9PSIsInZhbHVlIjoiZjcvRGlYSEJXSGIvanBuQmdPNlVnMENGWmxyTURPbGJNNHprUVV5ZDg5ck8rWXJCQ2FPM2FXZ2NCczRSVXVFNUlVRkpweVdHOGpYQnFTcUlGTk1MVTBaZG10UlprK3g1UitENUd6K0VWMklSSTBPNld1NG5pMU5jakN2c2taYWwiLCJtYWMiOiIyZTMyODQ4MjI4MjY1YmExMWZlNDdhNTdjZWIxZTQ3NDM5OTQ1NDY4OWExNWM0ZTE5YzBlNDk5ZjExMGY5ZTQ3IiwidGFnIjoiIn0%3D' \
-H 'dnt: 1' \
-H 'origin: https://example.com' \
-H 'pragma: no-cache' \
-H 'priority: u=0, i' \
-H 'referer: https://example.com' \
-H 'sec-ch-ua: "Google Chrome";v="141", "Not?A_Brand";v="8", "Chromium";v="141"' \
-H 'sec-ch-ua-mobile: ?0' \
-H 'sec-ch-ua-platform: "Windows"' \
-H 'sec-fetch-dest: document' \
-H 'sec-fetch-mode: navigate' \
-H 'sec-fetch-site: same-origin' \
-H 'sec-fetch-user: ?1' \
-H 'upgrade-insecure-requests: 1' \
-H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36' \
--data-raw '_token=&email=dibo%40example.com&name=Amal+Britt&mobile_number=1&workshop_date=inform_next_webinar&push-subscription-data=&g-recaptcha-response='

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post