Nginx: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| Line 1: | Line 1: | ||
{|class='wikitable' | |||
|- | |||
|valign='top' style='width:50%'| | |||
sudo apt install nginx | sudo apt install nginx | ||
|valign='top' style='width:50%'| | |||
|} | |||
==Virtual Host== | ==Virtual Host== | ||
< | {|class='wikitable mw-collapsible' | ||
!scope='col' style='text-align:left'| | |||
Virtual Host | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang='bash'> | |||
cat << EOF | tee /etc/nginx/sites-available/academia.chorke.org >/dev/null | cat << EOF | tee /etc/nginx/sites-available/academia.chorke.org >/dev/null | ||
server { | server { | ||
| Line 74: | Line 85: | ||
ln -s /etc/nginx/sites-available/academia.chorke.org\ | ln -s /etc/nginx/sites-available/academia.chorke.org\ | ||
/etc/nginx/sites-enabled/academia.chorke.org | /etc/nginx/sites-enabled/academia.chorke.org | ||
</ | </syntaxhighlight> | ||
|} | |||
==Reverse Proxy== | ==Reverse Proxy== | ||
===Reverse Proxy » MinIO== | {|class='wikitable mw-collapsible' | ||
- | !scope='col' style='text-align:left' colspan='2'| | ||
< | Reverse Proxy | ||
|- | |||
!scope='col' style='width:50%'| Reverse Proxy » MinIO | |||
!scope='col' style='width:50%'| | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang='bash'> | |||
MINIO_OPTS="--address :9800 --console-address :9801" | MINIO_OPTS="--address :9800 --console-address :9801" | ||
MINIO_VOLUMES="/home/minio/.minio/data" | MINIO_VOLUMES="/home/minio/.minio/data" | ||
| Line 86: | Line 104: | ||
MINIO_CONFIG_ENV_FILE=/etc/default/minio | MINIO_CONFIG_ENV_FILE=/etc/default/minio | ||
MINIO_BROWSER_REDIRECT_URL="http://academia.chorke.org/minio/" | MINIO_BROWSER_REDIRECT_URL="http://academia.chorke.org/minio/" | ||
</ | </syntaxhighlight> | ||
< | <syntaxhighlight lang='text'> | ||
location /minio/ { | location /minio/ { | ||
proxy_set_header Host $http_host; | proxy_set_header Host $http_host; | ||
| Line 99: | Line 117: | ||
proxy_pass http://127.0.0.1:9801/; | proxy_pass http://127.0.0.1:9801/; | ||
} | } | ||
</ | </syntaxhighlight> | ||
== | |valign='top'| | ||
- | |- | ||
< | !scope='col'| Reverse Proxy » ROR | ||
!scope='col'| | |||
|- | |||
|valign='top'| | |||
<syntaxhighlight lang='text'> | |||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | proxy_set_header X-Forwarded-Proto $scheme; | ||
| Line 116: | Line 138: | ||
proxy_pass http://127.0.0.1:3002; | proxy_pass http://127.0.0.1:3002; | ||
} | } | ||
</ | </syntaxhighlight> | ||
|valign='top'| | |||
|} | |||
==Knowledge== | ==Knowledge== | ||
{| | {|class='wikitable mw-collapsible' | ||
| valign= | !scope='col' style='text-align:left' colspan='3'| | ||
< | Knowledge | ||
|- | |||
|valign='top' style='width:33%'| | |||
<syntaxhighlight lang='bash'> | |||
ufw status | ufw status | ||
netstat -a | netstat -a | ||
| Line 127: | Line 155: | ||
apt install ufw | apt install ufw | ||
apt install nmap | apt install nmap | ||
</ | </syntaxhighlight> | ||
| valign= | |valign='top' style='width:34%'| | ||
< | <syntaxhighlight lang='bash'> | ||
sudo ss -tulwn | grep LISTEN | sudo ss -tulwn | grep LISTEN | ||
sudo ss -tulpn | grep LISTEN | sudo ss -tulpn | grep LISTEN | ||
| Line 136: | Line 164: | ||
sudo ss -tulpn | grep LISTEN | grep minio | sudo ss -tulpn | grep LISTEN | grep minio | ||
sudo ss -tulpn | grep LISTEN | grep resolve | sudo ss -tulpn | grep LISTEN | grep resolve | ||
</ | </syntaxhighlight> | ||
| valign= | |valign='top' style='width:33%'| | ||
< | <syntaxhighlight lang='bash'> | ||
sudo ufw status | sudo ufw status | ||
sudo ufw app list | sudo ufw app list | ||
| Line 145: | Line 173: | ||
sudo ss -tulpn | grep LISTEN | sudo ss -tulpn | grep LISTEN | ||
sudo lsof -i -P -n | grep LISTEN | sudo lsof -i -P -n | grep LISTEN | ||
</ | </syntaxhighlight> | ||
|- | |- | ||
|valign='top'| | |valign='top'| | ||
| Line 159: | Line 183: | ||
|valign='top'| | |valign='top'| | ||
|} | |} | ||
==References== | ==References== | ||
{| | {|class='wikitable mw-collapsible' | ||
| valign= | !scope='col' style='text-align:left' colspan='3'| | ||
References | |||
|- | |||
|valign='top' style='width:33%'| | |||
* [https://serverfault.com/questions/618669/ Proxy to sites that expect to be at root URL] | * [https://serverfault.com/questions/618669/ Proxy to sites that expect to be at root URL] | ||
* [[Virtual Host And Certbot in Raspbian 10]] | * [[Virtual Host And Certbot in Raspbian 10]] | ||
| Line 177: | Line 203: | ||
* [[MinIO]] | * [[MinIO]] | ||
| valign= | |valign='top' style='width:34%'| | ||
|valign='top' style='width:33%'| | |||
|} | |} | ||
Revision as of 03:05, 6 February 2026
sudo apt install nginx |
Virtual Host
|
Virtual Host |
|---|
cat << EOF | tee /etc/nginx/sites-available/academia.chorke.org >/dev/null
server {
server_name academia.chorke.org;
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 3;
gzip_buffers 64 8k;
gzip_disable "msie6";
gzip_min_length 1100;
gzip_http_version 1.0;
gzip_types text/css text/xml application/x-javascript application/atom+xml text/mathml text/plain text/vnd.sun.j2me.app-descriptor text/vnd.wap.wml text/x-component image/bmp image/svg+xml image/x-icon;
root /var/chorke/academia.chorke.org/www;
access_log /var/chorke/academia.chorke.org/logs/nginx.access.log;
error_log /var/chorke/academia.chorke.org/logs/nginx.error.log info;
error_page 500 502 503 504 /500.html;
client_max_body_size 25M;
keepalive_timeout 10;
expires $expires;
location ~ ^/.well-known(/.*|$) {
alias /var/www/html/.well-known$1;
gzip_static on;
expires max;
add_header Cache-Control public;
}
location ^~ /assets/ {
root /var/chorke/academia.chorke.org/www/assets;
gzip_static on;
expires max;
add_header Cache-Control public;
}
location /minio/ {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_buffering on;
proxy_buffer_size 8k;
proxy_buffers 2048 8k;
proxy_pass http://127.0.0.1:9801;
}
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/academia.chorke.org/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/academia.chorke.org/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
if ($host = academia.chorke.org) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name academia.chorke.org;
listen [::]:80;
listen 80;
return 404; # managed by Certbot
}
EOF
ln -s /etc/nginx/sites-available/academia.chorke.org\
/etc/nginx/sites-enabled/academia.chorke.org
|
Reverse Proxy
|
Reverse Proxy | |
|---|---|
| Reverse Proxy » MinIO | |
MINIO_OPTS="--address :9800 --console-address :9801"
MINIO_VOLUMES="/home/minio/.minio/data"
MINIO_ROOT_USER=admin
MINIO_ROOT_PASSWORD=academia
MINIO_CONFIG_ENV_FILE=/etc/default/minio
MINIO_BROWSER_REDIRECT_URL="http://academia.chorke.org/minio/"
location /minio/ {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering on;
proxy_buffer_size 8k;
proxy_buffers 2048 8k;
proxy_redirect off;
proxy_pass http://127.0.0.1:9801/;
}
|
|
| Reverse Proxy » ROR | |
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_redirect off;
location / {
proxy_pass http://127.0.0.1:3001;
}
location /api {
proxy_pass http://127.0.0.1:3002;
}
|
|
Knowledge
|
Knowledge | ||
|---|---|---|
ufw status
netstat -a
netstat -lpn
apt install ufw
apt install nmap
|
sudo ss -tulwn | grep LISTEN
sudo ss -tulpn | grep LISTEN
sudo ss -tulpn | grep LISTEN | grep sshd
sudo ss -tulpn | grep LISTEN | grep minio
sudo ss -tulpn | grep LISTEN | grep resolve
|
sudo ufw status
sudo ufw app list
sudo ufw allow 'Nginx HTTP'
sudo ss -tulpn | grep LISTEN
sudo lsof -i -P -n | grep LISTEN
|
apt install telnet apt list --installed netstat -uap|grep nginx |
||
References
|
References | ||
|---|---|---|