donderdag 2 december 2021

ip verkeer op server controleren

netstat -a -o -n


naar file : nestat -a -o -n > c:\log.txt


list services op server, ga naar dir:

c:\windows\system32\inetsrv\

gebruik: appcmd list site

om naar file te loggen: appcmd list site > d:\sites.log


woensdag 17 maart 2021

Tailwind css base styles

 How to apply base styles to Tailwind?

In tailwind all default styles are removed by the preflight functionality.

To add default style in your website/application

add a layer in the tailwind.css with the direction to base fe:

@tailwind base;
@tailwind components;
@tailwind utilities;

@tailwind screens;
@layer base {
p {
@apply mt-2;
}
h1{
@apply xs:text-2xl pt-10 sm:text-3xl md:text-5xl m-2 font-Primary text-primary font-normal;
}
h2{
@apply xs:text-2xl sm:text-3xl md:text-4xl text-secundary font-normal;
}
h3{
@apply xs:text-2xl sm:text-3xl md:text-4xl text-secundary font-normal;
}

}

woensdag 10 maart 2021

SSL in NGINX

 Get an SSL certificate via

https://www.sslforfree.com/  90 days is for free, only domain ssl, card is paid subscription

download the certificate and create an directory on your host where you can store the certicates.

the downloaded certicate files are:

private.key
certicate.crt
ca_bundle.crt

for instance copy the files to "/var/certs/", rename them to domain_certicate.crt and domain_private.key or create a subdirectory for your domain.


enable ssl on your firewall via 

ufw enable https or ufw enable 443


now edit you site configuration file in /etc/nginx/sites/available via nano.

following nginx configuration consists out of 3 parts to enforce ssl and https://www.

server1 : http incomming on //domain and www.domain with redirect to https://www

server2: https incomming on https://domain and redirect to https://www.domain and declaration for ssl cerficates.

server3: https incomming on https://www.domain which contains all configuation, in this example with no-cache for index.html and caching for images (react is used)


see: https://www.nginx.com/blog/creating-nginx-rewrite-rules/


server{

        listen 80;

        server_name domainname.com www.domainname.com

        return 301 https://www.$server_name$request_uri;

}


server {

        listen [::]:443 ssl;

        listen 443 ssl;

        ssl_certificate /var/certs/certificate.crt;

        ssl_certificate_key /var/certs/private.key;

        server_name domainname.com;

        return 301 https://www.$server_name$request_uri;

}


server {

        listen [::]:443 ssl http2 ipv6only=on;

        listen 443 ssl http2;

        ssl_certificate /var/certs/certificate.crt;

        ssl_certificate_key /var/certs/private.key;

        root /var/www/domainname/rootdir;

        index index.html;

        server_name www.domainname.com;


        access_log /var/log/nginx/domainname.com.access.log;

        error_log /var/log/nginx/domainname.com.error.log;


        location ~* \.(jpg|jpeg|png|gif|ico|css|js|webp)$ {

                expires 365d;

        }


        location / {

                try_files $uri /index.html =404;

                add_header Cache-Control "no-cache";

        }

}

after saving reload nginx and restart.


zaterdag 6 maart 2021

currency formatting javascript / typescript

export const toDutchCurrency = (value: number): string =>
{
const formatter = new Intl.NumberFormat('nl-NL', {
style: 'currency',
currency: 'EUR',
});
return formatter.format(value);
}

bron: mozilla

zondag 28 februari 2021

nginx setup ubuntu

 update repositories:

sudo apt-get update

install nginx

sudo apt-get install nginx

check version of nginx

nginx -v

check status of nginx

sudo systemctl status nginx

start nginx

sudo systemctl start nginx

stop nginx : sudo systemctl stop nginx

set nginx to start at reboot server / system starts:

sudo systemctl enable nginx

when to disable at system start: sudo systemctl disable nginx

reload nginx after configuration is changed:

sudo systemctl reload nginx

hard restart of nginx:

sudo systemctl restart nginx

installeer firewall:

sudo apt-get install ufw

start/enable firewall:

sudo ufw enable  

check apps in firewall:

sudo ufw app list

Enable nginx http calls through the firewall:

sudo ufw allow 'nginx http'

Enable nginx https: sudo ufw allow 'nginx https'

to enable http and https: sudo ufw allow 'nginx full'

after setting reload firewall: sudo ufw reload

Check if nginx server is running using curl:

install curl: sudo apt-get install curl
run check: curl -i http://127.0.0.1

DON'T FORGET TO OPEN PORT 22 for SSH

sudo ufw allow 22/tcp 

or sudo ufw allow ssh

In Nginx, a server block is a configuration that works as its own server. By default, Nginx has one server block preconfigured.
It is located at /var/www/html. However, it can be configured with multiple server blocks for different sites.

Create testdomain/testwebsite:

sudo mkdir -p /var/www/test_domain.com/html

create index.html and fill it with contents:

sudo nano /var/www/test_domain.com/html/index.html

Edit configuation for the site, all configuration is located in /etc/nginx/sites-available

sudo nano /etc/nginx/sites-available/test_domain.com

nice article to follow:

https://phoenixnap.com/kb/how-to-install-nginx-on-ubuntu-20-04


maandag 25 januari 2021

Next js with typescript intall

 

create new app with

yarn create next-app

yarn is default used 

Add tsconfig.json file to root of application

Add typescript to project

yarn add --dev typescript @types/react @types/node

run yarn dev and the tsconfig.json file will be populated with the right content.

Rename all components and pages from .js to .tsx