使用 nginx 实现前(Angular)后(Springboot)端分离 并代理为一个网站

 

 

nginx 

复制代码
server {
    listen       9191;
    root E:\HelloProject\dist;
    index  index.html index.htm;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    #添加头部信息
    proxy_set_header Cookie $http_cookie;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    location / {
        proxy_pass http://localhost:9090;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host:$server_port; #重点重定向会导致oAuth2找不到正确的重定向地址
    }
    location /login {
        try_files $uri $uri/login /login/index.html;
    }

    # error_page   500 502 503 504  /50x.html;
    # location = /50x.html {
    #     root   html;
    # }
}
复制代码

 

 

引用:

1、nginx中部署发布angular应用

https://blog.csdn.net/yunfeng482/article/details/87204844

2、SpringBoot 实现前后端分离的跨域访问(Nginx)

https://www.jianshu.com/p/520021853827

3、关于 Nginx 反向代理导致 Spring Boot OAuth2 认证失败的问题

https://blog.csdn.net/github_39939645/article/details/87829944

 

posted @   三瑞  阅读(397)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现
历史上的今天:
2016-01-12 IBatisNet不常用到的配置(Dao.config ConnectionTimeout),居然不起作用(前辈留给我们的坑)
点击右上角即可分享
微信分享提示