NGINX篇 九月 25, 2023

Nginx upstream 根据自定义 hash 规则进行路由

文章字数 1.2k 阅读约需 1 mins.

upstream MDM_WS {
    hash '$proxy_add_x_forwarded_for';
    server mdm:6611;
    server mdm-slave:6611...
查看全文

NGINX篇 六月 15, 2023

Nginx 反向代理配置多个前缀匹配

文章字数 678 阅读约需 1 mins.

配置场景:
有时我们有多个前缀需要反向代理到同一个后端服务,
比如 /s1, /s2, /s3-xxx, 都代理到同一个后端服务
最普通的写法可以写多个 location 来匹配, 这里介绍使用一个 location 完成匹配

    location ~* ^/(s1|s2|s3-*)/ {
       proxy_pass http://GATEWAY;

       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header...
查看全文

NGINX篇 六月 14, 2023

Nginx 反向代理配置二级路径前缀

文章字数 416 阅读约需 1 mins.

使用场景: 前端访问的路径为 http://xxx:xx:/p1/p2/p3?p=xx

代理到后端的地址也是: http://xxx:xx:/p1/p2/p3?p=xx
现在想代理到后端的地址加一个前缀,变成 http://xxx:xx:/p0/p1/p2/p3?p=xx

    location /p1 {
       proxy_pass http://xxx:xx/p0/$request_uri;
    }
查看全文

NGINX篇 十月 20, 2021

Nginx 配置非 80 和 443 端口设置HTTP请求自动跳转HTTPS

文章字数 839 阅读约需 1 mins.

配置 https:

listen       80 ssl;
ssl_certificate /etc/nginx/conf.d/epark.ahhtk.com.pem;
ssl_certificate_key /etc/nginx/conf.d/epark.ahhtk.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4...
查看全文

NGINX篇 十月 10, 2021

Nginx 反向代理 TCP 端口

文章字数 672 阅读约需 1 mins.

stream {

    upstream rabbit {
    server 172.30.241.82:5672;
    }

    server{
    listen 45672;
    proxy_pass rabbit;
    }
}

stream 放到和 http 同一级

别忘了开启防火墙端口

firewall-cmd --zone=public --add-port=45672/tcp --permanent
firewall-cmd --reload

如果提示错误 unknown directive "stream...

查看全文
加载更多
0%