Nginx 反向代理/vue訪問..等*.conf設置
各種應用在 nginx 反向代理/vue頁面訪問的配置,陸續更新。
Nginx 反向代理 phpmyadmin容器 並且指定路徑
server {
# ... 其他配置 ...
location /pma/ {
proxy_pass http://phpmyadmin:80/; # 注意這裡最後的斜線很重要
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
docker-compose phpmyadmin 環境變量
phpmyadmin:
image: phpmyadmin:${phpMyAdmin_VERSION}
container_name: phpmyadmin
restart: always
environment:
- PMA_ARBITRARY=1
- PMA_HOST=${phpMyAdmin_HOST}
- UPLOAD_LIMIT=${phpMyAdmin_UPLOAD_LIMIT}
- TZ=${TZ}
- PMA_ABSOLUTE_URI=https://abc.example.com/qaktjq #設定要跳轉的域名
ports:
- ${phpMyAdmin_HTTP_PORT}:80
stdin_open: true
tty: true
logging:
driver: "json-file"
options:
max-size: "1g" # 设置最大日志文件大小为1GB
max-file: "3" # 设置最大日志文件数量
networks:
- backendNet
- shared-network
vue 頁面訪問
server{
listen 80;
# listen 443 ssl ;
# http2 on ;
# server_name ;
root /app;
# vue rewrite
set $index_page 'index.html';
index $index_page;
location / {
if (!-e $request_filename){
rewrite ^/(.*) /$index_page;
}
}
#限制客户端请求体的最大大小。如果客户端发送的请求体超过此大小,Nginx将返回413 Request Entity Too Large响应
client_max_body_size 15M;
client_body_buffer_size 1M;
## enable ssl
# if ($server_port !~ 443){
# rewrite ^(/.*)$ https://$host$1 permanent;
# }
# ssl_certificate ssls/;
# ssl_certificate_key ssls/;
}
常用反向代理
server {
listen 80;
server_name pma.test.com;
# 打開檔案大小限制
client_max_body_size 300M;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://phpmyadmin;
}
}
Telegram BOT
location /tgbot {
proxy_pass https://t.me/telebot/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host t.me;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
Jenkins
server {
listen 443 ssl http2;
server_name jenkins.test.com;
location / {
proxy_pass http://127.0.0.1:8080; # 将此更改为 Jenkins 的内部地址和端口
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# 支持 WebSocket 的反向代理
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# 防止连接超时
proxy_read_timeout 90;
proxy_connect_timeout 90;
proxy_send_timeout 90;
}
ssl_certificate ssls/test/cert.pem;
ssl_certificate_key ssls/test/key.pem;
}