环境:CentOS 7
Nginx根目录:/etc/nginx/
server {
listen 80;
server_name localhost;
location / {
root html; # 指定根目录下的静态文件目录(相对)
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# 设置反向代理
location /v/ {
proxy_pass http://xxx.com/api/;
}
}

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My nginx server</title>
</head>
<body>
<h3 style="text-align: center">^(* ̄(oo) ̄)^</h3>
<div id="json"></div>
<script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/axios/0.19.0/axios.min.js"></script>
<script type="text/javascript">
function textAjax() {
axios.post(‘/v/test/get‘, {mode:‘test‘})
.then(function (response) {
console.log(response);
$(‘#json‘).html(JSON.stringify(response))
})
.catch(function (error) {
console.log(error);
});
}
$(function () {
textAjax();
});
</script>
</body>
</html>
(*^__^*) ,粗略记录,后期慢慢记录补充~
原文:https://www.cnblogs.com/gme5/p/11727680.html