У меня есть блог о пеликане с простой страницей контактов.
Страница контактов использует js для отправки POST-запроса к PHP-скрипту, который выполняет SMTP-запрос для отправки электронного письма. Когда я пытаюсь сделать это в веб-браузере, это не работает, и если я использую curl, я получаю ошибку 405:
✗ curl -H "Content-Type: application/json" -X POST -d '{"name":"PM","email":"p@m.com", "message":"foo"}' https://pm.com/theme/send-form.php
<html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx/1.10.3 (Ubuntu)</center>
</body>
</html>
Моя директива о местоположении nginx выглядит так:
location / {
# Serve a .gz version if it exists
gzip_static on;
# Try to serve the clean url version first
try_files $uri.html $uri.html $uri =404;
# allow POST on static pages
error_page 405 =200 $uri;
}
location ~ \.php$ {
# If a file isn't found, 404
try_files $uri =404;
#Include Nginx's fastcgi configuration
include /etc/nginx/fastcgi.conf;
#Look for the FastCGI Process Manager
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
Я черпал вдохновение для этой директивы о местоположении: https://linuxconfig.org/basic-php-7-and-nginx-configuration-on-ubuntu-16-04-linux
Тем не менее, он все еще не работает, и самое досадное в том, что ни в одном из журналов доступа / ошибок nginx или php7.0-fpm не обнаружено никаких ошибок.