todo

nginx配置,代理,转发

up:2025-03-12 08:49:23 edit:2025-03-12 08:57:43 view:266

#系统服务

开机自启 systemctl enable nginx



Nginx

方便起见,不安装为系统服务,从源码编译
https://nginx.org/en/docs/configure.html
https://stackoverflow.com/questions/30979618/how-to-deploy-nginx-without-root-access
https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/

Bash#xingng-es-test3wget https://nginx.org/download/nginx-1.24.0.tar.gz#

./configure --prefix=~/nginxmake

&& make installcd ~/nginx


#密码文件生成#install apache2-utils (Debian, Ubuntu) or httpd-tools (RHEL/CentOS/Oracle Linux).

htpasswd -c htpasswd2.txt elastic

# content like, pass is xxx:$apr1$nfEdxAl$osv7qCFxxxOzenl1

#or plain format

#user:{PLAIN}pass# echo 'elxxc:$apr1$nfExxl$osv7xxxxxenl1' > htpasswd2.txt

#put in conf dir./sbin/nginx

#启用./sbin/ngins -s reload

#reload config




server{
listen 19200;
#默认1m
client_max_body_size 20m;
location / {
auth_basic "Administrator’s Area";
auth_basic_user_file htpasswd.txt;
proxy_pass http://localhost:9200;
}
}



server {
listen 5602;
server_name _;
location / {
return 301 http://xxxx.nip.io/;
}
}


#转发带上auth
server {
listen 9200;
location / {
proxy_pass http://xxxx:19200;
proxy_set_header Authorization "Basic xxxx";
}

}





not in sinaapp