Skip to content

Instantly share code, notes, and snippets.

@ncole458
ncole458 / default
Created May 2, 2018 01:58
React app breaks on refresh NGINX
# update the location blocks try_files in your /sites-available/default
location / {
try_files $uri $uri/ /index.html$is_args$args;
}
@ncole458
ncole458 / mime.types
Last active April 18, 2018 01:41
Fix Nginx fonts not working
# add below to /etc/nginx/mime.types
application/x-font-ttf ttc ttf;
application/x-font-otf otf;
application/font-woff woff;
application/font-woff2 woff2;
application/vnd.ms-fontobject eot;
# add below to /sites/available/your-site
location ~* \.(eot|otf|ttf|woff|woff2)$ {
add_header Access-Control-Allow-Origin *;
@ncole458
ncole458 / cli.txt
Last active May 19, 2018 11:30
WordPress FTP permissions on VPS/EC2 etc
# allow WP to FTP/access core/plugin folders
sudo chown -R www-data /var/www/html
# always set back when done
sudo chown -R sammy /var/www/html
# restart PHP on Ubuntu
sudo service php7.0-fpm restart
@ncole458
ncole458 / gunicorn.sock
Last active April 20, 2018 10:53
Fix Gunicorn socket with Nginx not working
# Fix Gunicorn socket with Nginx not working
# create a new gunicorn sock (for nginx)
https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04#create-a-gunicorn-systemd-service-file
# NGINX - make sure same sock so nginx can talk to Gunicorn!
upstream app_server {
server unix:/home/django/django_project/MyAPIName/mysockname.sock fail_timeout=0;
}
@ncole458
ncole458 / style.scss
Created February 25, 2018 09:03
Fix Carousel in Bootstrap 4
// FIX BOOTSTRAP CAROUSEL WHITE-SPACE BETWEEN SLIDES
.carousel-item {
transition: -webkit-transform 0.5s ease !important;
transition: transform 0.5s ease !important;
transition: transform 0.5s ease, -webkit-transform 0.5s ease !important;
-webkit-backface-visibility: visible !important;
backface-visibility: visible !important;
}
@ncole458
ncole458 / default
Created December 11, 2017 03:36
How to get an A rating on Qualys ssllabs.com SSL Report
# full nginx conf for Django w/web-sockets
upstream app_server {
server 127.0.0.1:9000 fail_timeout=0;
}
upstream websocket {
server 127.0.0.1:8002 fail_timeout=0;
}
@ncole458
ncole458 / urls.py
Created October 17, 2017 03:17
Easy Django static file route for SSL validation etc.
# place file in static root
from django.views.generic.base import RedirectView
from django.contrib.staticfiles.storage import staticfiles_storage
urlpatterns = [
url(r'C798C4F2FDD57D2D63BF76874C080F49.txt', RedirectView.as_view(
url=staticfiles_storage.url('C798C4F2FDD57D2D63BF76874C080F49.txt'),
permanent=True),
@ncole458
ncole458 / django
Last active October 2, 2017 02:48
Full Django>Gunicorn>NGINX Config w/WebSockets
upstream app_server {
server 127.0.0.1:9000 fail_timeout=0;
}
upstream websocket {
server 127.0.0.1:8001 fail_timeout=0;
}
#server {
# listen 80;
@ncole458
ncole458 / gunicorn.conf
Last active October 2, 2017 02:50
Gunicorn for Django/nginx
# gunicorn.conf
description "Gunicorn app server for Django Project"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
setuid username
setgid www-data
@ncole458
ncole458 / websockets.html
Created September 28, 2017 05:38
WebSockets Testing
<!DOCTYPE html>
<html lang="en" dir="ltr" class="no-js">
<head>
<title>WebSockets</title>
<script language="javascript" type="text/javascript">
var wsUri = "wss://url.com.au/websockets/";
var output;