Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

How i did SSL with let's encrypt for free

I use ubuntu v14 on vps machine. I have couple nodejs scripts running with pm2. I use https server inside js files:

const app = require('express')();

const fs = require('fs');
var privateKey = fs.readFileSync('/etc/letsencrypt/live/domain.com/privkey.pem'); // privatekey.pem
var certificate = fs.readFileSync('/etc/letsencrypt/live/domain.com/cert.pem'); // certificate.pem
var chain = fs.readFileSync('/etc/letsencrypt/live/domain.com/fullchain.pem'); // certificate.pem
const https = require('https').Server({
  key: privateKey,
  cert: certificate,
  ca: chain}, app);


In nginx i use this:

    server {
      listen 443 ssl;

      server_name domain.com www.domain.com;

     ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
     ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;

      keepalive_timeout 10;

      location /.well-known/acme-challenge/ {
        alias /var/www/challenges/;
        try_files $uri =404;
      }

      location / {
          proxy_redirect off;
          proxy_set_header   X-Real-IP         $remote_addr;
          proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
          proxy_set_header   X-Forwarded-Proto $scheme;
          proxy_set_header   Host              $http_host;
          proxy_set_header   X-NginX-Proxy     true;
          proxy_set_header   Connection        "";
          proxy_pass         http://pm2upstream;
     }



    }


Tried different guides and failed.

This worked:

  1. wget https://dl.eff.org/certbot-auto
  2. chmod a+x ./certbot-auto
  3. service nginx stop
  4. ./certbot-auto certonly  & follow instructions, use auto server
  5. reboot 0     // i hear you screaming about this, best wishes, sys admins

MongoDB: fixed not starting error

Just use these:

sudo -u mongodb mongod --repair --dbpath /var/lib/mongodb/
sudo service mongodb start

Of course change dbpath to your dbpath, this one is default.

Basic Auth .htaccess 101

All these are working on Ubuntu 13.04

1. Check if apache modules are loaded:

on ubuntu this one works find:
apache2ctl -M

 auth_basic_module (shared)
 authn_file_module (shared)
 authz_default_module (shared)
 authz_groupfile_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
not all required, but my config is loading these now. auth_... and authn_... are realy required for my example, but i don't know which of those authz are required..

php5/ext/pcre/php_pcre.h:29:18: fatal error: pcre.h: No such file or directory while installing php zip

I was trying to use ZipArchive, but i got an error:
Fatal error: Class 'ZipArchive' not found
Then I started to Google how to install zip extension on my Ubuntu Apache 2 server. I have PHP version 5.3.10 and in configuration it says, that zip is enabled. This information you can get with these 2 simple commands: