Skip to content

Instantly share code, notes, and snippets.

@Celoxocis
Created March 18, 2018 11:36
Show Gist options
  • Save Celoxocis/040b44c5f0d7f894f758266ea60cfaab to your computer and use it in GitHub Desktop.
Save Celoxocis/040b44c5f0d7f894f758266ea60cfaab to your computer and use it in GitHub Desktop.
NGinx reverse proxy (in a Docker environment)
# source https://www.n0r1sk.com/index.php/2017/04/20/wordpress-ssl-https-and-reverse-proxy-nginx-apache-httpd/
#
<VirtualHost ${IP}:443>
worker_processes auto;
events {
worker_connections 4096;
}
http {
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
ssl_prefer_server_ciphers on;
server_tokens off;
log_format basic '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent"';
upstream n0r1sk_wp {
hash $remote_addr;
server tasks.n0r1sk_wp_app:80;
}
server {
listen 443 ssl http2;
server_name n0r1sk.com www.n0r1sk.com;
ssl on;
ssl_certificate <path to your fullchain.pem>;
ssl_certificate_key <path to your privkey.pem>;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA
256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:AES128-SHA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4;
error_log /var/log/nginx/n0r1sk_error.log info;
access_log /var/log/nginx/n0r1sk_access.log basic;
location / {
sendfile off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://n0r1sk_wp;
}
}
server {
listen 80;
server_name n0r1sk.com www.n0r1sk.com;
return 302 https://$server_name$request_uri;
error_log /var/log/nginx/n0r1sk_error.log info;
access_log /var/log/nginx/n0r1sk_access.log basic;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment