Welcome! Log In Create A New Profile

Advanced

Error in nginx configuration

Posted by Yakov_Myagkov 
Error in nginx configuration
June 22, 2020 03:46AM
Hello everyone, I am just starting my way to NGINX and I need a pro answer. There is CentOS7 on which GLPI + Nginx is installed. Everything seems to work without problems, but I encountered such a problem that you need to work with the GLPI API and there is a jamb, based on the documentation for the GLPI API, the URL is accessed by the following http: //MyWebGLPI/apirest.php/, when navigating through this link I get 404 Not Foung nginx (in the logs there is the following entry: 2020/06/22 10:32:09 [error] 10309 # 10309: * 15 "/var/www/glpi/apirest.php/index.php" is not found (20: Not a directory), client: xxxx, server: MyWebGLP, request: "GET /apirest.php/ HTTP / 1.1", host: "MyWebGLP") That is, he thinks that I want to go through the directory and this is a clear error in the configuration file, BUT, if you remove "/" from the URL and the link looks like this: http: //MyWebGLPI/apirest.php, then everything works out as it should, but this is not correct. Here is the configuration file, what is the error?

### support.sevo44.ru
server {
listen 80;
listen [::]:80;


root /var/www/glpi/;
index index.php index.html index.htm;

access_log /var/www/glpi/log/access.log;
error_log /var/www/glpi/log/error.log;

# Include phpmyadmin
#include /etc/nginx/snippets/phpMyAdmin.conf;


set_real_ip_from 10.0.0.0/8;
real_ip_header X-Real-IP;


client_max_body_size 10m;

keepalive_timeout 60;
add_header Strict-Transport-Security 'max-age=604800';

location / {
try_files $uri =404;
autoindex on;
}

location ~* ^.+.(js|css|png|jpg|jpeg|gif|ico|woff)$ {
access_log off;
expires max;
}

location /api {
rewrite ^/api/(.*)$ /apirest.php/$1 last;
}

location ~ \.php$ {
try_files $uri = 404;
fastcgi_index index.php;
fastcgi_pass unix:/run/php-fpm/MyWebGLPI.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SERVER_NAME $host;
fastcgi_param HTTPS on;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_param PHP_VALUE "
memory_limit = 64M
file_uploads = on
max_execution_time = 600
session.auto_start = off
session.use_trans_sid = 0
";
}

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
#allow all;
deny all;
log_not_found off;
access_log off;
}

location ~ /\.ht {
deny all;
}
}



Edited 1 time(s). Last edit at 06/22/2020 03:51AM by Yakov_Myagkov.
Re: Error in nginx configuration
June 23, 2020 08:43AM
I close the topic, since I figured out this question myself, who cares, I will lay out my configuration in which NGINX started accessing the URL correctly.

server {
listen 80 default_server;
listen [::]: 80 default_server;
server_name MyGlpiWeb;

root / var / www / glpi /;
index index.php index.html index.htm;

access_log /var/www/glpi/log/access.log;
error_log /var/www/glpi/log/error.log;

# Include phpmyadmin
#include /etc/nginx/snippets/phpMyAdmin.conf;


set_real_ip_from 10.0.0.0/8;
real_ip_header X-Real-IP;


client_max_body_size 10m;

keepalive_timeout 60;
add_header Strict-Transport-Security 'max-age = 604800';

location / {
try_files $ uri $ uri / = 404;
autoindex on;
}

location / api {
rewrite ^ / api /(.*)$ /apirest.php/$1 last;
}

location ~ [^ /] \. php (/ | $) {
fastcgi_pass unix: / run / php-fpm / MyGlpiWeb .sock;

# regex to split $ uri to $ fastcgi_script_name and $ fastcgi_path
fastcgi_split_path_info ^ (. + \. php) (/.+) $;

# Check that the PHP script exists before passing it
try_files $ fastcgi_script_name = 404;

# Bypass the fact that try_files resets $ fastcgi_path_info
# # see: http://trac.nginx.org/nginx/ticket/321
set $ path_info $ fastcgi_path_info;
fastcgi_param PATH_INFO $ path_info;

fastcgi_param PATH_TRANSLATED $ document_root $ fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;

include fastcgi_params;

# allow directory index
fastcgi_index index.php;
}
}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 55
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready