nginx配置反代理协议和SSL证书

举报
沃通WoTrus 发表于 2021/11/12 16:05:44 2021/11/12
【摘要】 nginx配置反向代理,负载均衡配置;upstreamqq_com {ip_hash;server127.0.0.1:8080;server127.0.0.1:8081;}server {listen80;server_namewww.qq.com;location/{proxy_passhttp://qq_com;proxy_set_headerHost$host;proxy_set_he...

nginx配置反向代理,负载均衡配置;

upstreamqq_com {

ip_hash;

server127.0.0.1:8080;

server127.0.0.1:8081;

}

server {

listen80;

server_namewww.qq.com;

location/

{

proxy_passhttp://qq_com;

proxy_set_headerHost$host;

proxy_set_headerX-Real-IP$remote_addr;

proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;

}

}

nginx 配置SSL

server

{

listen443;

server_namea.com;

indexindex.htmlindex.php;

root/data/nginx/a.com;

sslon;

ssl_certificatecert/215058855400123.pem;

ssl_certificate_keycert/215058855400123.key;

ssl_protocolsTLSv1TLSv1.1TLSv1.2;

location/{

root/home/www/a.com;

indexindex.htmlindex.htm;

}

access_log/tmp/1.logcombined_realip;

}

nginx 配置静态目录

server{

listen8088;

server_namelocalhost;

#charsetkoi8-r;

#access_loglogs/host.access.logmain;

location~.*\.(gif|jpg|jpeg|png)${

expires24h;

rootusr/local/image/;#指定图片存放路径

access_logusr/local/image/images.log;#日志存放路径

proxy_storeon;

proxy_store_accessuser:rwgroup:rwall:rw;

proxy_temp_pathsr/local/image/;#图片访问路径

proxy_redirectoff;

proxy_set_headerHost127.0.0.1;

client_max_body_size10m;

client_body_buffer_size1280k;

proxy_connect_timeout900;

proxy_send_timeout900;

proxy_read_timeout900;

proxy_buffer_size40k;

proxy_buffers40320k;

proxy_busy_buffers_size640k;

proxy_temp_file_write_size640k;

if(!-e$request_filename)

{

proxy_passhttp://127.0.0.1;

}

}

nginx 用户认证

server

{

listen80;

server_nametest.com;

index index.htmlindex.htmindex.php;

root/data/wwwroot/test.com;

location/

{

auth_basic"Auth";

auth_basic_user_file/usr/local/nginx/conf/htpasswd;

}

}

yuminstall-yhttpd

htpasswd-c/usr/local/conf/htpasswdaming

./nginx-sreload

【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。