Nginx反向代理配置
安装Nginx
sudo apt update
sudo apt-get install -y nginx
写入配置文件
无域名状态下使用https进行访问
server {
listen 443 ssl;
#---------error_page页面------------------
error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 421 422 423 424 425 426 428 429 431 451 500 501 502 503 504 505 506 507 508 510 511 /upgrade.html;
location = /upgrade.html {
root /usr/share/nginx/html;
internal;
}
#---------------------------
server_name 示例IP;
# 证书路径
ssl_certificate /etc/nginx/cert/dyinnovations.com.pem;
ssl_certificate_key /etc/nginx/cert/dyinnovations.com.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
# 代理到某个地址
location / {
gzip on;
gzip_comp_level 1;
gzip_min_length 10k;
gzip_types text/html text/plain application/json;
# 需要代理的地址
proxy_pass http://127.0.0.1:8088;
proxy_set_header Host $host;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header QQ https;
}
}
server {
listen 80;
server_name 示例IP;
rewrite ^(.*)$ https://$host$1;
location / {
gzip on;
gzip_comp_level 1;
gzip_min_length 10k;
gzip_types text/html text/plain application/json;
proxy_pass http://127.0.0.1:8088;
proxy_set_header Host $host;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header QQ https;
}
}
没有回应