博客
关于我
Nginx 反向代理解决跨域问题
阅读量:796 次
发布时间:2023-02-15

本文共 824 字,大约阅读时间需要 2 分钟。

最近在项目中遇到了跨域相关的问题,经过对比几种跨域解决方案后,决定采用Nginx的方式进行处理。以下是实际项目中的Nginx配置参考,其中10.12.1.210为Nginx所在机器的IP地址,80端口是Nginx监听端口(可以同时监听多个端口),具体配置代码如下:

server {    listen       80 default_server;    listen       [::]:80 default_server;    server_name  localhost;    location / {        root /usr/share/nginx/html/PaaS/;        try_files $uri /index.html;        index index.html;    }    location /oas-cloud {        proxy_set_header X-Real-IP $remote_addr;        proxy_pass http://10.12.1.210:30003/oas-cloud;    }    location /zuul {        proxy_set_header X-Real-IP $remote_addr;        proxy_pass http://10.12.1.210:30003/zuul;    }

以上配置文件主要用于Nginx作为反向代理,实现不同路径的访问转发处理。通过设置proxy_set_header,可以记录客户端的真实IP地址,确保后续日志记录和访问权限管理的准确性。配置中/oas-cloud/zuul路径对应的反向代理目标分别为http://10.12.1.210:30003/oas-cloudhttp://10.12.1.210:30003/zuul,实现了对相应路径的访问转发。

转载地址:http://clcfk.baihongyu.com/

你可能感兴趣的文章
NI笔试——大数加法
查看>>
NLP 基于kashgari和BERT实现中文命名实体识别(NER)
查看>>
Nmap扫描教程之Nmap基础知识
查看>>
Nmap端口扫描工具Windows安装和命令大全(非常详细)零基础入门到精通,收藏这篇就够了
查看>>
NMAP网络扫描工具的安装与使用
查看>>
NN&DL4.1 Deep L-layer neural network简介
查看>>
NN&DL4.3 Getting your matrix dimensions right
查看>>
NN&DL4.8 What does this have to do with the brain?
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>
No resource identifier found for attribute 'srcCompat' in package的解决办法
查看>>
No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
查看>>