热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Nginx代理实现跨域

#usernobody;worker_processes1;#error_loglogserror.log;#error_loglogserror.lognotice;#error
#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;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location /html {
            root   html;
            index  index.html index.htm;            
        }     

        location / {
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Credentials true;
            add_header Access-Control-Allow-Methods GET,POST,OPTIONS;            
            add_header Access-Control-Allow-Headers DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type;
            proxy_pass   http://localhost:8090/XXX-web/;
        }



        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache‘s document root
        # concurs with nginx‘s one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # 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代理实现跨域


推荐阅读
  • #include#includeintmain(){printf(floorof2.3is%d\n,(int)floor(2.3));printf(floorof ... [详细]
  • ProblemDescription:Readtheprogrambelowcarefullythenanswerthequestion.#pragmacomment(linker ... [详细]
  • python 解决多张相同的excel取某一些数据合同到一张EXCEL
    这样的表单有几百张把姓名和从事专业类别代码的值取出合并到一张总表里importpandasaspdimportos#第一步读取文件储存在是s列表中pathD:001#文件夹目录fi ... [详细]
  • Matplotlib笔记:设置画布属性并保存图片(figsize,dpi,savefig)
    设置画布属性并保存图片importmatplotlib.pyplotaspltplt.figure(figsize(10,4),dpi80)#图片长宽和清晰度plt.p ... [详细]
  • PICT初探索
    pict用于测试用例的生成,非常高效。也非常方便。安装完成后主要程序就一个exe文件。需要通过cmd命令行进入pict文件夹。建立测试用例文件然后使用简单的命令行生成测试用例也可以 ... [详细]
  • 内存暴增排查分析
    一次偶然间,发现测试环境iis站点内存突然间暴增,平常都是300M,这次一下子暴增到8g于是就开始了接下来的分析发现Dictionary居然有1.78g懵逼windbg分析1.看看 ... [详细]
  • 1011-MarriageCeremoniesPDF(English)StatisticsForumTimeLimit:2second(s)MemoryLimit:32MBYouw ... [详细]
  • 726:ROADS726:ROADS总时间限制:1000ms内存限制:65536kB描述Ncitiesnamedwithnumbers1Nareconnectedwithon ... [详细]
  • AtCoder Beginner Contest 176   EBomber   (思维)
    题意:有一张$H$x$W$的图,给你$M$个目标的位置,你可以在图中放置一枚炸弹,炸弹可以摧毁所在的那一行和一列,问最多可以摧毁多少目标.题解:首先我们记录某一行和某一列目标最多的 ... [详细]
  • String字符串java.lang;基本标识Java字符串的一个重要特点就是字符串不可变。finalclassString没有子类字符串字面量也是一个String类的实例存储在字 ... [详细]
  • 一步一步学EF系列【4、升级篇 实体与数据库的映射】
    之前的三张为基础篇,如果不考虑架构问题,做一般的小程序,以足够用了。基本的增删改查也都有了。但是作为学习显然是不够的。通过之前三章的学习,有没有发现这样写有什么问题,有没有觉得繁琐 ... [详细]
  • re正则表达式1.什么是正则?正则就是用一系列具有特殊含义的字符组成的规则,该规则用来描述具有某一特征的字符串。正则就是用来在一个大的字符串匹配出符合规则的子字符串2.为什么用正则 ... [详细]
  • python+selenium+chrome网页自动化测试:1、在pycharm中安装selenium:file-setting-projectinterpreter中搜索sele ... [详细]
  • 串口初始化D8120说明:※根据MD320的通讯协议,无帧头和帧尾,则(bit9,bit8)(0,0)。※bit13~15是计算机链接通讯时的设定项目,使用RS指令时必须设定为0。 ... [详细]
  • iometer 1.1.0 重要特性说明之Write IO Data Pattern
    iometer1.1.0版本包含了3种WriteIODataPattern。分别是:Repeatingbytes、Pseudo-Random(2006.07.27及其之前的版本默认 ... [详细]
author-avatar
陈杰倩平贵奕白
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有