Skip to content

Instantly share code, notes, and snippets.

View KavenTheriault's full-sized avatar

Kaven Thériault KavenTheriault

View GitHub Profile
@KavenTheriault
KavenTheriault / Nginx_Uwsgi.md
Last active November 23, 2021 23:28
ArchLinux nginx+uwsgi+flask

Dependencies

$ pacman -S python-pip nginx uwsgi-plugin-python uwsgi

Directories

$ /etc/nginx/ (nginx directory)
$ /etc/uwsgi/ (uwsgi directory)
$ /usr/share/nginx/uswgi_test/ (app directory)
@KavenTheriault
KavenTheriault / TracingWCF.md
Last active October 20, 2017 12:27
Enabling Tracing in Windows Communication Foundation

Add this to config file

Make sure the destination folder exist

  <configuration>  
     <system.diagnostics>  
        <sources>  
              <source name="System.ServiceModel"   

switchValue="Information, ActivityTracing"

@KavenTheriault
KavenTheriault / Debian.md
Last active November 21, 2017 23:47
uwsgi+nginx+flask on Debian 8

Host flask api in Nginx using UWSGI

In this exemple of configuration. All communications sent to localhost/api will be sent to the uwsgi socket.

Dependencies

$ apt-get install python python-pip build-essential python-dev uwsgi-plugin-python
$ pip install uwsgi

Directories

@KavenTheriault
KavenTheriault / sshfs.md
Created August 20, 2017 22:12
Mount remote drive via SSH

Mount remote drive via SSH

sshfs -o allow_other {user}@{ip}:{remote_dir} {local_dir}

allow_other => Allow other users than the mounter (i.e. root) to access the share.

sudo mkdir /mnt/chicago_vps

sudo sshfs -o allow_other zoidqc@107.172.11.251:/ /mnt/chicago_vps

@KavenTheriault
KavenTheriault / windows_in_grub.md
Last active February 16, 2019 14:03
Configure Windows partition in grub

Configure Windows partition in grub

List all devices

lsblk

Look at the UUID of your Windows 10 partition, for exemple:

sudo blkid /dev/sda2
@KavenTheriault
KavenTheriault / nginx_reverse_proxy.md
Last active February 21, 2020 22:52
Configure Nginx Reverse Proxy as failover

Configure Nginx Reverse Proxy as failover

In this exemple of configuration, if the first server fail (proxy_connect_timeout) one time (max_fails), the second server will be used for 60s (fail_timeout).

The SSL certificate need to be configure on the ReverseProxy server AND the proxyied servers. You can use the same certificate and configurations on all servers.

To test the configuration you can change your host file to simulate the correct domain name.

Use the following tool to configure SSL with optimal configuration.

@KavenTheriault
KavenTheriault / EntityCommand.md
Last active November 8, 2017 19:52
Entity command example

Install package with specific version

Install-Package EntityFramework -version 6.1.3

Run migration for specific connection string name

Update-Database -ConnectionStringName applicationDB2

Add migration with name "AddStateToUser" and compare database structure from specific connection string name

@KavenTheriault
KavenTheriault / extract_private_key_from_pfx.md
Last active November 15, 2017 20:26
How to extract certificate information (including private key) from pfx file

How to extract certificate information (including private key) from pfx file

Use openssl to extract private key. After executing the following line. you will need to enter the password used when the pfx file was created.

openssl pkcs12 -in file_name.pfx -out certificate.cer -nodes

When converting a PFX file to PEM format, OpenSSL will put all the certificates and the private key into a single file. You will need to open the file in a text editor and copy each certificate and private key (including the BEGIN/END statments) to its own individual text file and save them as certificate.cer, CACert.cer, and privateKey.key respectively.

@KavenTheriault
KavenTheriault / redirect_http_to_https.md
Last active November 16, 2017 23:47
Nginx - Redirect http to https

Create file the following file /etc/nginx/site-available/redirect_http_to_https

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    return 301 https://$host$request_uri;
}

Create symbolic link in the /etc/nginx/site-enabled/ folder

@KavenTheriault
KavenTheriault / a_plus_ssl_conf_nginx.md
Last active November 16, 2017 23:29
A+ SSL Test Nginx configuration

Generate your own key for DHE ciphers (ssl_dhparam)

$ sudo openssl dhparam -out /etc/ssl/dhparam.pem 2048

Trusted certificate (ssl_trusted_certificate)

Point to a trusted certificate chain file. This must contain the intermediate & root certificates (in that order from top to bottom). See exemple_full_chain.pem

Get the root and intermediate certificates from where you buyed the certificates. For me it was: