Categories
Uncategorized

Reverse proxy with nginx and Prometheus on Centos 7

After installing ngxinx using yum install, create a prometheus config

touch /etc/nginx/conf.d/prometheus.conf
emacs /etc/nginx/conf.d/prometheus.conf

Add the following to prometheus.conf

server {
       listen 80;
       listen [::]:80;
       server_name      prometheus.local;

       location / {
                proxy_pass      http://localhost:9090/;
       }
}

Restart nginx, now you should be able to access http://prometheus.local

Add HTTPS support

The cert was done with mkcert and the files moved to a directory in /etc/nginx/mkcerts. Change the port to 9090 to load the prometheus site, port 3000 points to grafana.

server {
       listen 80;
       listen 443 ssl;

       ssl_certificate /etc/nginx/mkcerts/prometheus2.local.pem;
       ssl_certificate_key /etc/nginx/mkcerts/prometheus2.local-key.pem;

       server_name      prometheus2.local;
       location / {
                proxy_pass      http://localhost:3000/;
       }

}

Add Basic Authentication to prometheus

First install

yum install httpd-tools

Now create the password

htpasswd -c /etc/nginx/.htpasswd username

Now modify /etc/nginx/conf.d/prometheus.conf

server {
       listen 80;
       listen 443 ssl;

       ssl_certificate /etc/nginx/mkcerts/prometheus2.local.pem;
       ssl_certificate_key /etc/nginx/mkcerts/prometheus2.local-key.pem;

       auth_basic  "Protected Area";
       auth_basic_user_file /etc/nginx/.htpasswd;

       server_name      prometheus2.local;
       location / {
                proxy_pass      http://localhost:9090/;
       }

}

Restart prometheus

Categories
Uncategorized

nginx 403 error on Centos 7

I had modified the default root config of /etc/nginx/nginx.conf from

server {
...
       #root         /usr/share/nginx/html; 
...
}

To

server {
...
       root         /var/www/default;
...
}

I created a folder and index.html

mkdir -p /var/www/default
chown -R nginx:nginx /var/www/default
chmod -R 755 /var/www/default
touch /var/www/default/index.html (I then added some content to this file)
chmod 644 /var/wwww/default/index.html

After restarting nginx I got a 403 error, this was due to SELinux. The fix

sudo setsebool -P httpd_can_network_connect on
getenforce
chcon -Rt httpd_sys_content_t /var/www/default/
Categories
Uncategorized

Reset Windows admin password

Boot from a flash drive, select repair, troubleshoot, command prompt

cd windows\system32
copy utilman.exe utilman.old
copy cmd.exe utilman.exe
reboot

Click on the the Easy of Access icon (botton right corner), this will open a command prompt

net user # this will show the list of local users
net user /add newusername newuserpassword # add a new user with given password
net localgroup administrators newusername /add #add new user to admin group

Categories
Uncategorized

ZFS set/get user quota

zfs set userquota@username=10g tankname/dirname
zfs get userquota@username tankname/dirname

Check disk space usage

zfs userspace tankname/dirname