Lubuntu <<
Previous Next >> Bind
Windows
nginx 設定為各用戶可以透過 public_html 共用全球資訊網伺服器:
nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen [::]:80 default_server;
server_name s4.eng.nfu.edu.tw;
# 主網站根目錄
root C:/nginx-1.28.0/html;
index index.html;
# user 個人網站
location ~ ^/~([^/]+)(/.*)?$ {
set $user $1;
set $subpath $2;
if ($subpath = "") { set $subpath "/"; }
# Windows 可以強制用正斜線
set $home C:/Users/$user/public_html$subpath;
# 若無 public_html 則傳回 404
if (!-d C:/Users/$user/public_html) {
return 404;
}
alias $home;
autoindex on;
}
# 主要檔案服務
location / {
try_files $uri $uri/ =404;
}
# 全局禁止 .git、.htaccess 等隱藏檔
location ~ /\.(?!well-known).* {
deny all;
access_log off;
log_not_found off;
}
}
}
上述 nginx.conf 設定完成後,以 nssm install nginx 配置以服務執行 nginx.exe 後,再允許 nginx.exe 接受防火牆的輸入原則連線:
http://s4.eng.nfu.edu.tw/~pj2023
Lubuntu <<
Previous Next >> Bind