Listener_txd

键盘一响,黄金万两,键盘敲烂,年薪百万

nginx 反向代理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
nginx.conf
 
http {
  
 server {
        listen       80;
        server_name  localhost;
 
        location ^~ /api {
            root   html;
            index  index.html; 
            proxy_pass  http://localhost:5000/api;#前面加http
            proxy_redirect     off;
            proxy_set_header   Host             $host;        # 传递域名
            proxy_set_header   X-Real-IP        $remote_addr; # 传递ip
            proxy_set_header   X-Scheme         $scheme;      # 传递协议
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }
 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

  

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <button onclick="send()">send</button>
 
  <script>
    const send = () => {
      const xhr = new XMLHttpRequest()
      xhr.open('get', 'http://localhost/api/getData')
      xhr.send()
      xhr.onload = () => {
        console.log(xhr.responseText)
      }
    }
  </script>
</body>
</html>

  

 
 
 
 
 
posted @   adong搬砖  阅读(6)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
点击右上角即可分享
微信分享提示