Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrestDB + Postgresql + Nginx #42

Open
munirkn opened this issue Jan 12, 2017 · 1 comment
Open

ArrestDB + Postgresql + Nginx #42

munirkn opened this issue Jan 12, 2017 · 1 comment

Comments

@munirkn
Copy link

munirkn commented Jan 12, 2017

We are trying hard from last two weeks to configure ArrestDB with Postgresql on Nginx server. We get following error:

{
"error": {
"code": 400,
"status": "Bad Request"
}
}

while requesting like: http://serverip/ArrestDB/index.php/users

Note: We have successfully deployed this API with Postgresql on Apache server.

@vasilevich
Copy link

vasilevich commented Mar 3, 2017

Hi,
I don't know if thats the optimal way to do this but:
at file: index.php
replace the line at:

$root = preg_replace('~/++~', '/', substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])) . '/');

with
$root = preg_replace('~/++~', '/',$_SERVER['REQUEST_URI'] . '/');

NGINX config that worked for me:

server {

	server_name	example.com;
	root /path/to/where/the/file/is/;
	location / {

		index index.php;
		try_files $uri $uri/ /index.php?$query_string;
	}

	location ~ \.php {

		try_files $uri =404;
		fastcgi_split_path_info ~(.+\.php)(/.+)$;
		fastcgi_read_timeout 9999m;
		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_NAME $fastcgi_script_name;
		fastcgi_param SCRIPT_FILENAME $request_filename;
		fastcgi_param REQUEST_URI $request_uri;
		fastcgi_param DOCUMENT_URI $document_uri;
		fastcgi_param DOCUMENT_ROOT $document_root;
		fastcgi_param SERVER_PROTOCOL $server_protocol;
		fastcgi_param GATEWAY_INTERFACE CGI/1.1;
		fastcgi_param SERVER_SOFTWARE nginx;
		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 SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_param SCRIPT_NAME $fastcgi_script_name;
		fastcgi_index index.php;

		fastcgi_pass unix:/run/php-fpm/php-fpm.sock;

	}

}

hope I helped, good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants