Commit bc8f97b2 authored by thiaramus's avatar thiaramus
Browse files

Added docker nginx environment

parent 4d1217e4
......@@ -24,8 +24,13 @@
$user = false;
$apiKey = filter_input(INPUT_SERVER, 'HTTP_X_API_TOKEN', FILTER_SANITIZE_STRING);
$apiUsername = filter_input(INPUT_SERVER, 'HTTP_X_API_USERNAME', FILTER_SANITIZE_STRING);
// Apache
//$apiKey = filter_input(INPUT_SERVER, 'HTTP_X_API_TOKEN', FILTER_SANITIZE_STRING);
//$apiUsername = filter_input(INPUT_SERVER, 'HTTP_X_API_USERNAME', FILTER_SANITIZE_STRING);
// NGINX
$apiKey = array_key_exists('HTTP_X_API_TOKEN', $_SERVER) ? $_SERVER['HTTP_X_API_TOKEN'] : NULL;
$apiUsername = array_key_exists('HTTP_X_API_USERNAME', $_SERVER) ? $_SERVER['HTTP_X_API_USERNAME'] : NULL;
if ($apiKey != NULL) {
if (hash_equals(hash('sha256', $apiKey), $cfg['users'][$apiUsername]['password'])) {
......
......@@ -37,7 +37,11 @@
require_once 'include/init.inc.php';
// Grab request URI and parse it into the array
$uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING);
// Apache
//$uri = filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING);
// NGINX
$uri = array_key_exists('REQUEST_URI', $_SERVER) ? $_SERVER['REQUEST_URI'] : NULL;
$parsedUri = parse_url($uri);
// Generate apiClass name from the first URI keyword.
......
version: '2'
services:
jameditor-api:
build: ./images/lnp
ports:
- "80:80"
volumes:
- ../:/var/www/jameditor-api
- ../fidosample/fidoconf:/usr/local/etc/fidoconf
- ../fidosample/messagebase:/var/fido/messagebase
- ../fidosample/nodelist:/var/fido/nodelist
environment:
# Windows Docker
ENABLE_XDEBUG: 1
XDEBUG_CONFIG: remote_host=10.0.75.1
# Linux Docker
# XDEBUG_CONFIG: remote_host=172.18.0.1
\ No newline at end of file
FROM richarvey/nginx-php-fpm
COPY config/jameditor-api.local.conf /etc/nginx/sites-available/default.conf
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/jameditor-api/api;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name jameditor-api.local;
# Disable sendfile as per https://docs.vagrantup.com/v2/synced-folders/virtualbox.html
sendfile off;
# Add stdout logging
error_log /dev/stdout info;
access_log /dev/stdout;
# Add option for x-forward-for (real ip when behind elb)
#real_ip_header X-Forwarded-For;
#set_real_ip_from 172.16.0.0/12;
location / {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
include fastcgi_params;
}
error_page 404 /404.html;
location = /404.html {
root /var/www/errors;
internal;
}
location ^~ /sad.svg {
alias /var/www/errors/sad.svg;
access_log off;
}
location ^~ /twitter.svg {
alias /var/www/errors/twitter.svg;
access_log off;
}
location ^~ /gitlab.svg {
alias /var/www/errors/gitlab.svg;
access_log off;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|webp|tiff|ttf|svg)$ {
expires 5d;
}
# deny access to . files, for security
#
location ~ /\. {
log_not_found off;
deny all;
}
location ^~ /.well-known {
allow all;
auth_basic off;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment