Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Applications
API on NGNIX
marcosan
November 2019
Hi,
I'm migrating a FuelPHP API application from Apache to NGINX but I keep getting a 404 from NGNIX.
I'm using NGINX 1.16, PHP 7.3 and Debian 8
My config is as follows:
Server {
listen 3;
server_name xxx.xx.xx.xx;
access_log /opt/bitacora/nginx/logs/api-access.log;
error_log /opt/bitacora/nginx/logs/api-error.log debug;
root /opt/bitacora/api/public;
location / {
index index.php
try_files $uri $uri/ /index.php$args;
proxy_set_header Host $host;
#error_page 404 /index.php$args;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_intercept_errors on;
fastcgi_index index.php;
fastcgi_param FUEL_ENV "production";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
If I uncomment the "
error_page 404 /index.php$args;" line then all my GET requests work but not the POST, PUT or DELETE.
Harro
November 2019
POST doesn't work either? That is very weird?
And do you get a 404 or a 405 on PUT, PATCH and DELETE?
marcosan
November 2019
Hi Harro,
Yes, I get a 404 failed(2: No such file or directory) on POST, PUT and DELETE
Harro
November 2019
I'm travelling atm, I can see if I can setup nginx when I'm back. All our apps run on Apache, so this is new for me too.
atabak
November 2019
try:
try_files $uri $uri/ /index.php$is_args$args;
and remove
fastcgi_intercept_errors on;
marcosan
November 2019
Did tried without the fastcgi_intercept_errors and the $is_args but still no luck
atabak
November 2019
nginx config file in virtualmin i install now and work:
Nginx 1.14.0
php 7.4
ubuntu server 18.04
ip address : 000.000.000.000
domain name = domain.com
server {
server_name domain.com www.domain.com;
listen 000.000.000.000;
root /home/domain/public_html;
index index.html index.htm index.php;
access_log /var/log/virtualmin/domain.com_access_log;
error_log /var/log/virtualmin/domain.com_error_log;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME /home/domain/public_html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /home/domain/public_html;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTPS $https;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
listen 000.000.000.000:443 default ssl;
ssl_certificate /home/domain/ssl.cert;
ssl_certificate_key /home/domain/ssl.key;
}
what is error log file say?
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
atabak
November 2019
Harro
November 2019
marcosan
November 2019