Skip to content

Instantly share code, notes, and snippets.

@xiocode
Last active December 8, 2016 13:53
Show Gist options
  • Save xiocode/d3335179c1560bcff3a8 to your computer and use it in GitHub Desktop.
Save xiocode/d3335179c1560bcff3a8 to your computer and use it in GitHub Desktop.
自定义Go Get路径

安装dhparam

openssl dhparam -out /etc/nginx/dhparam.pem 2048

/path/to/nginx/site-enabled/xxx.xxx.com.conf

server {
  listen 443 ssl;
  listen [::]:443 ssl;
  server_name xxx.xxx.com;
  root /root/www/public;
  access_log  /var/log/nginx/xxx.xxx.com.https.log;

  # certs sent to the client in SERVER HELLO are concatenated in ssl_certificate
  ssl_certificate /etc/letsencrypt/live/xxx.xxx.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/xxx.xxx.com/privkey.pem;
  ssl_session_timeout 1d;
  ssl_session_cache shared:SSL:50m;
  #ssl_session_tickets off;

  # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
  # openssl dhparam -out /etc/nginx/dhparam.pem 2048
  ssl_dhparam /etc/nginx/dhparam.pem;

  # modern configuration. tweak to your needs.
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK';
  ssl_prefer_server_ciphers on;

  # HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)
  add_header Strict-Transport-Security max-age=15768000;

  # OCSP Stapling ---
  # fetch OCSP records from URL in ssl_certificate and cache them
  ssl_stapling on;
  ssl_stapling_verify on;

  ## verify chain of trust of OCSP response using Root CA and Intermediate certs
  ssl_trusted_certificate /etc/letsencrypt/live/xxx.xxx.com/chain.pem;

  resolver 8.8.8.8 8.8.4.4 valid=86400;
  resolver_timeout 10;


  location ~ /(?<namespace>[a-z][a-z0-9]*)/(?<package>[a-z][a-z0-9]*) {
        if ($args = "go-get=1") {
                add_header Content-Type text/html;
                return 200 '<meta name="go-import" content="$host/$namespace/$package git https://github.com/$namespace/$package">';
        }
  }

}
@xiocode
Copy link
Author

xiocode commented Jan 29, 2016

https://certbot.eff.org/#debianjessie-nginx
sudo apt-get install certbot -t jessie-backports

## 生成证书

certbot certonly --standalone --email [email protected] -d example.com -d www.example.com

@xiocode
Copy link
Author

xiocode commented Jan 29, 2016

certbot.renew

#!/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
service nginx stop
/usr/bin/certbot renew --standalone --force-renew
service nginx start

@xiocode
Copy link
Author

xiocode commented Dec 8, 2016

30 3 1 * * (/path/to/certbot.renew >> /var/log/certbot.renew.log 2>&1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment