Skip to content

Instantly share code, notes, and snippets.

@kamerk22
Created June 25, 2017 06:15
Show Gist options
  • Save kamerk22/00b80ad624288358ab4fc9c75a143099 to your computer and use it in GitHub Desktop.
Save kamerk22/00b80ad624288358ab4fc9c75a143099 to your computer and use it in GitHub Desktop.
Nginx Configuration running PHP7.0-FPM Fast CGI with phpmyadmin and MySQL, Reverse proxy with NodeJS application
server {
listen 80 default_server;
server_name dev ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /phpmyadmin {
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.htpasswd;
root /usr/share/nginx/html;
index index.php index.html index.htm;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location /mynodeapp {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_max_temp_file_size 0;
proxy_pass http://mynodeapp;
# ex: http://localhost:3000
proxy_redirect off;
proxy_read_timeout 240s;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment