.kanban/Barcode-Host/tasks/setup-nginx.md
2024-06-03 07:25:11 -07:00

132 lines
3.1 KiB
Markdown

---
status: "4-Done"
type: "kanbn"
created: "2024-01-06T01:22:07.445Z"
updated: "2024-01-06T01:22:07.445Z"
---
# setup-nginx
```bash
echo >/etc/nginx/sites-available/default && nano /etc/nginx/sites-available/default
```
```conf
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
```
```bash
systemctl restart nginx
lsof -i -P -n | grep LISTEN
links http://192.168.0.204/
nginx -t
nginx -s reload
echo >/etc/nginx/sites-available/Barcode-Host-Server && nano /etc/nginx/sites-available/Barcode-Host-Server
```
```conf
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
```
```bash
echo >/home/unity4/localhost.conf && nano /home/unity4/localhost.conf
```
```conf
[req]
default_bits = 2048
default_keyfile = localhost.key
distinguished_name = req_distinguished_name
req_extensions = req_ext
x509_extensions = v3_ca
[req_distinguished_name]
countryName = Country Name (2 letter code)
countryName_default = US
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = Arizona
localityName = Locality Name (eg, city)
localityName_default = Mesa
organizationName = Organization Name (eg, company)
organizationName_default = Infineon Technologies Americas Corp.
organizationalUnitName = organizationalunit
organizationalUnitName_default = Development
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_default = unity4
commonName_max = 64
[req_ext]
subjectAltName = @alt_names
[v3_ca]
subjectAltName = @alt_names
[alt_names]
DNS.1 = unity4
DNS.2 = localhost
DNS.3 = 127.0.0.1
```
```bash
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/localhost.key -out /etc/nginx/localhost.crt -config /home/unity4/localhost.conf
ls /etc/nginx
echo >/etc/nginx/sites-available/Barcode-Host-Server && nano /etc/nginx/sites-available/Barcode-Host-Server
```
```conf
server {
server_name _;
ssl_certificate 'localhost.crt';
listen 443 default_server ssl http2;
ssl_certificate_key 'localhost.key';
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
error_page 500 502 503 504 /50x.html;
listen [::]:443 default_server ssl http2;
location / {
proxy_pass http://localhost:5003;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
```
```bash
ln -s /etc/nginx/sites-available/Barcode-Host-Server /etc/nginx/sites-enabled/Barcode-Host-Server
nginx -t
nginx -s reload
links https://localhost/api/lastscan
links https://unity4/api/lastscan
```
```conf
# C:\Windows\System32\drivers\etc\hosts
192.168.0.204 unity4
```
## Sub-tasks
- [x] phares3757
- [x] unity4
- [x] unity5