网站首页 > 技术教程 正文
话不多说直接先上nginx代码
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
#这里代理本地80端口的项目
server {
listen 80;
server_name 192.168.48.244;
# 允许跨域请求的域, * 表示所有
add_header 'Access-Control-Allow-Origin' *;
# 允许携带Cookie
add_header 'Access-Control-Allow-Credentials' 'true';
# 允许请求的方式 比如常用的Restful GET/PUT/POST/DELETE
add_header 'Access-Control-Allow-Methods' *;
# 允许请求的header
add_header 'Access-Control-Allow-Headers' *;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
location /health-admin/ {
proxy_pass http://127.0.0.1:8201;
}
location /admin-app/ {
proxy_pass http://127.0.0.1:8601;
}
location /mall-admin/ {
proxy_pass http://127.0.0.1:8801;
}
location /health-portal/ {
proxy_pass http://127.0.0.1:8202;
}
location /mall-app/ {
proxy_pass http://127.0.0.1:8802;
}
location /uc-app/ {
proxy_pass http://127.0.0.1:8701;
}
location /cfg-app/ {
proxy_pass http://127.0.0.1:8201;
}
location /chronic-admin/ {
proxy_pass http://127.0.0.1:8202;
}
location /net-hospital-admin/ {
proxy_pass http://127.0.0.1:8202;
}
location /admin-app/health-admin {
proxy_pass http://127.0.0.1:8201/health-admin;
}
location /admin-app/mall-admin {
proxy_pass http://127.0.0.1:8801/mall-admin;
}
location /admin-app/health-portal {
proxy_pass http://127.0.0.1:8202/health-portal;
}
location /admin-app/net-hospital-admin {
proxy_pass http://127.0.0.1:8202/net-hospital-admin;
}
location /admin-app/mall-app {
proxy_pass http://127.0.0.1:8802/mall-app;
}
location /admin-app/news-app {
proxy_pass http://127.0.0.1:7802/news-app;
}
#location /ecan-admin-front/ {
# root E:/ideaProjects/;
#}
#或者 alias是全替换location root是root路径拼接location
location /ecan-admin-front/ {
alias E:/ideaProjects/ecan-admin-front/;
}
}
#这里是代理本地8085转发到本地8081 skywalking服务 增加超时配置以及
server {
listen 8085;
server_name localhost;
client_max_body_size 151m;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
auth_basic "s1"; #虚拟主机认证命名
auth_basic_user_file E:/passwd.db; #虚拟主机用户名密码认证数据库
proxy_connect_timeout 300; #nginx跟后端服务器连接超时时间(代理连接超时)默认60s
proxy_read_timeout 300; #后端服务器数据回传时间(代理发送超时)默认值60s
proxy_send_timeout 300; #连接成功后,后端服务器响应时间(代理接收超时)默认值60s
proxy_pass http://127.0.0.1:8081;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
nginx鉴权需要先安装apach服务 在apach服务 bin目录下生成密码
结果 8085 和8081端口都可以访问
nginx鉴权弹窗 因为之前登录过 这里修改下nginx代理端口 重启nginx
好了,你学会了吗?
猜你喜欢
- 2024-10-09 程序员都应该懂的微服务容错与隔离:熔断保护、超时与重试原理
- 2024-10-09 Nginx为什么快到根本停不下来?(nginx解决什么问题)
- 2024-10-09 Nginx代理webSocket经常中断的解决方案,如何保持长连接
- 2024-09-09 怎么测试nginx反向代理(nginx反向代理配置参数)
- 2024-09-09 关于LNMP+Frp内网穿透环境下一个PHP程序运行超时的问题
- 2024-09-09 Nginx反向代理(nginx是干嘛用的)
- 2024-09-09 Nginx这么香,还不知道怎么学?看完这份Nginx笔记你能立马上手
- 2024-09-09 「每天一道面试题」Nginx 502错误原因和解决方法
- 2024-09-09 年轻人你不讲武德,Nginx之负载均衡演示
- 2024-09-09 应用程序加固Nginx篇(如何给应用加固)
你 发表评论:
欢迎- 最近发表
-
- Win11学院:如何在Windows 11上使用WSL安装Ubuntu
- linux移植(Linux移植freemodbus)
- 独家解读:Win10预览版9879为何无法识别硬盘
- 基于Linux系统的本地Yum源搭建与配置(ISO方式、RPM方式)
- Docker镜像瘦身(docker 减小镜像大小)
- 在linux上安装ollama(linux安装locale)
- 渗透测试系统Kali推出Docker镜像(kali linux渗透测试技术详解pdf)
- Linux环境中部署Harbor私有镜像仓库
- linux之间传文件命令之Rsync傻瓜式教程
- 解决ollama在linux中安装或升级时,通过国内镜像缩短安装时长
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)