宝塔nginx http转https代理

可以在网站配置里配置,也可以在nginx主配置文件里配置

主配置文件

worker_rlimit_nofile 51200;

stream {

log_format tcp_format 'time_local\|remote_addr|protocol\|status|bytes_sent\|bytes_received|session_time\|upstream_addr|upstream_bytes_sent\|upstream_bytes_received|$upstream_connect_time';

access_log /www/wwwlogs/tcp-access.log tcp_format;

error_log /www/wwwlogs/tcp-error.log;

include /www/server/panel/vhost/nginx/tcp/*.conf;

}

events

{

use epoll;

worker_connections 51200;

multi_accept on;

}

http

{

include mime.types;

#include luawaf.conf;

include proxy.conf;

lua_package_path "/www/server/nginx/lib/lua/?.lua;;";

default_type application/octet-stream;

server_names_hash_bucket_size 512;

client_header_buffer_size 32k;

large_client_header_buffers 4 32k;

client_max_body_size 50m;

sendfile on;

tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

fastcgi_connect_timeout 300;

fastcgi_send_timeout 300;

fastcgi_read_timeout 300;

fastcgi_buffer_size 64k;

fastcgi_buffers 4 64k;

fastcgi_busy_buffers_size 128k;

fastcgi_temp_file_write_size 256k;

fastcgi_intercept_errors on;

gzip on;

gzip_min_length 1k;

gzip_buffers 4 16k;

gzip_http_version 1.1;

gzip_comp_level 2;

gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/json image/jpeg image/gif image/png font/ttf font/otf image/svg+xml application/xml+rss text/x-js;

gzip_vary on;

gzip_proxied expired no-cache no-store private auth;

gzip_disable "MSIE 1-6\.";

limit_conn_zone $binary_remote_addr zone=perip:10m;

limit_conn_zone $server_name zone=perserver:10m;

server_tokens off;

access_log off;

server

{

listen 80;

server_name hpytg.com;

index index.html index.htm default.htm default.html;

root /var/ad/app/ad;

#SSL-START SSL相关配置

#error_page 404/404.html;

#SSL-END

#ERROR-PAGE-START 错误页相关配置

#error_page 404 /404.html;

#error_page 502 /502.html;

#ERROR-PAGE-END

#REWRITE-START 伪静态相关配置

include /www/server/panel/vhost/rewrite/go_ad.conf;

#REWRITE-END

#禁止访问的文件或目录

location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md|package.json|package-lock.json|\.env) {

return 404;

}

#一键申请SSL证书验证目录相关设置

location /.well-known/ {

root /www/wwwroot/java_node_ssl;

}

#禁止在证书验证目录放入敏感文件

if ( uri \~ "\^/\\.well-known/.\*\\.(php\|jsp\|py\|js\|css\|lua\|ts\|go\|zip\|tar\\.gz\|rar\|7z\|sql\|bak)" ) {

return 403;

}

HTTP反向代理相关配置开始 >>>

location ~ /purge(/.*) {

proxy_cache_purge cache_one 127.0.0.1request_uriis_args$args;

}

location / {

proxy_pass https://127.0.0.1:8081;

proxy_set_header Host 127.0.0.1:$server_port;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header REMOTE-HOST $remote_addr;

add_header X-Cache $upstream_cache_status;

proxy_set_header X-Host host:server_port;

proxy_set_header X-Scheme $scheme;

proxy_connect_timeout 30s;

proxy_read_timeout 86400s;

proxy_send_timeout 30s;

proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection "upgrade";

}

HTTP反向代理相关配置结束 <<<

access_log /www/wwwlogs/ad.log;

error_log /www/wwwlogs/ad.error.log;

}

server

{

listen 888;

server_name phpmyadmin;

index index.html index.htm index.php;

root /www/server/phpmyadmin;

#error_page 404 /404.html;

include enable-php.conf;

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

{

expires 30d;

}

location ~ .*\.(js|css)?$

{

expires 12h;

}

location ~ /\.

{

deny all;

}

access_log /www/wwwlogs/access.log;

}

include /www/server/panel/vhost/nginx/*.conf;

}

相关推荐
sudebao点com3 小时前
一次“Google 能打开,FlexTV 打不开”的 DNS 故障排查:从 curl 超时到完整证据链
windows·macos·https·cdn·dns·nslookup·网络排错
g10565591394 小时前
LAMP博客平台Wordpress实战
android·mysql·nginx·php
ControlRookie8 小时前
第15篇_Client 04|GET、POST 和 Body 怎样保持一致
http·codesys·plc通信·controlrookie
CDN3608 小时前
流媒体加速实践:出海东南亚短视频点播频繁缓冲,HLS 分片与 Nginx 配置调优
java·网络·nginx·流媒体加速
月落汀兰13 小时前
Linux Nginx全套实战通关|静态站点/虚拟主机/HTTPS/PHP/反向代理/七层负载均衡,每行命令逐参数拆解
linux·nginx·https
张小姐的猫13 小时前
【Linux】网络编程 —— 传输层协议 TCP(下)
linux·运维·服务器·网络·tcp/ip·http·php
tryCbest1 天前
Vue3项目在Nginx中配置代理后端IP
nginx·vue3
就叫飞六吧1 天前
DeepSeek Harness 本地安装与启动指南
nginx
難釋懷1 天前
Nginx主动健康检查
运维·nginx
运维全栈笔记1 天前
致远 OA HTTPS 配置避坑指南
网络协议·http·https