网站制作学习网经验与学习→正文:nginx 配置conf直接返回测试nginx可用
字体:

nginx 配置conf直接返回测试nginx可用

经验与学习 2024/10/29 14:54:05  点击:不统计

原载于:文章来源:www.forasp.cn网站制作学习

在nginx 配置文件中直接返回,不用使用代理,用于测试nginx 可用性
配置文件如下:
(1)直接返回 txt文本形式
   server {
listen 80;
server_name forasp.cn;
location /test {
# default_type text/plain; (二选一)
add_header 'Content-Type' 'text/plain';
return 200 'This is test content';
}
}
   
(2)直接返回 json 格式形式
   server {
listen 80;
server_name forasp.cn;
location /test {
# default_type application/json; (二选一)
add_header 'Content-Type' 'application/json';
return 200 '{"message": "Hello, this is a direct response from Nginx"}';
}
}
   
 
 
 

·上一篇:nginx指定多域名跨域 >>    ·下一篇:windows power shell 安装显示目录git扩展oh-my-posh >>
推荐文章
最新文章