1、nginx下部署网站
网站为:http://10.1.75.177:8000
nginx端口为80
配置如下:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
upstream webServer {
server 10.1.75.177:8000;
}
server {
listen 80;
server_name 10.1.75.177;
location / {
proxy_pass http://webServer/;
proxy_set_header Host $host:$server_port;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
含义说明:
https://www.runoob.com/w3cnote/nginx-setup-intro.html
2、nginx为web站点的访问设置账户和密码
http://www.04007.cn/article/605.html(重点参考)
https://www.cnblogs.com/wangxiaoqiangs/p/6184181.html(其他参考)
原配置
auth_basic_user_file /opt/modules/nginx/htpas;
修改为
auth_basic_user_file /opt/modules/nginx/htpas/htpasswd;
创建密码:nginx 123456
cd /opt/modules/nginx/htpas/
/usr/bin/htpasswd -bdc htpasswd nginx 123456
创建账号后,重启nginx
nginx -s stop
nginx
再次访问nginx下的web,需要账号和密码