/
nginx webserver http and https

nginx webserver http and https


HTTP

apt-get update
apt-get upgrade
apt-get install nginx

sudo systemctl start nginx
sudo systemctl enable nginx

??? /etc/init.d/nginx start
sudo systemctl status nginx
directory/var/www/html
test with curlcurl localhost

ip ad

curl http://192.168.0.139

Add folder
create a foldermkdir /var/www/html/files/
add permition

chown -R www-data:www-data /var/www/html/files/

chmod -R 755 /var/www/html/files/

to see the folder in the browser

vi /etc/nginx/sites-available/default

location /files/ {
     autoindex on; # Enable directory listing
     autoindex_exact_size off; # Optional: Show file sizes in a more readable format
     autoindex_localtime on; # Optional: Show file modification times in local time
}

test new configsudo nginx -t
reload the new config

sudo systemctl reload nginx

http://192.168.0.139/files/


HTTPShttps://techexpert.tips/nginx/enable-https-nginx/

apt-get install openssl

mkdir /etc/nginx/certificate
cd /etc/nginx/certificate
openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out nginx-certificate.crt -keyout nginx.key


config
writing new private key to 'nginx.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:UK
State or Province Name (full name) [Some-State]:Wales
Locality Name (eg, city) []:Pembrey
Organization Name (eg, company) [Internet Widgits Pty Ltd]:SSR testing dot com
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:192.168.226.100  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< IP address
Email Address []:jkriker@juniper.net
root@boxed:/etc/nginx/certificate# 
modify and add the HTTPS config

vi /etc/nginx/sites-available/default


443 https
server {
        . . . 
        # SSL configuration
        #
        listen 443 ssl default_server;
        listen [::]:443 ssl default_server;
        ssl_certificate /etc/nginx/certificate/nginx-certificate.crt;
        ssl_certificate_key /etc/nginx/certificate/nginx.key;

}

service nginx restart
Page size
64
100
500
1000
1400



pip3 install wget

https
import wget
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
url_64='http://192.168.0.140/64_index.html'
url_100='http://192.168.0.140/64_index.html'
url_500='http://192.168.0.140/500_index.html'
url_1000='http://192.168.0.140/1000_index.html'
url_1400='http://192.168.0.140/1400_index.html'
wget.download(url_64,'64_index.html.dw')






Related content

nginx container
nginx container
More like this
Dockerfile or create a customized image
Dockerfile or create a customized image
More like this
1- nginx container with dockers
1- nginx container with dockers
More like this
ssl proxy show commands
ssl proxy show commands
More like this
flask server with https
flask server with https
More like this
certificate on pycharm postman and curl
certificate on pycharm postman and curl
More like this