zoukankan      html  css  js  c++  java
  • Nginx跨域配置方法

    配置文件如下,重点在49~52行

      1 #user  nobody;
      2 worker_processes  1;
      3 
      4 #error_log  logs/error.log;
      5 #error_log  logs/error.log  notice;
      6 #error_log  logs/error.log  info;
      7 
      8 #pid        logs/nginx.pid;
      9 
     10 
     11 events {
     12     worker_connections  1024;
     13 }
     14 
     15 
     16 http {
     17     include       mime.types;
     18     default_type  application/octet-stream;
     19 
     20     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
     21     #                  '$status $body_bytes_sent "$http_referer" '
     22     #                  '"$http_user_agent" "$http_x_forwarded_for"';
     23 
     24     #access_log  logs/access.log  main;
     25 
     26     sendfile        on;
     27     #tcp_nopush     on;
     28 
     29     #keepalive_timeout  0;
     30     keepalive_timeout  65;
     31 
     32     #gzip  on;
     33 
     34     server {
     35         listen       88;
     36         server_name  localhost;
     37 
     38         #charset koi8-r;
     39 
     40         #access_log  logs/host.access.log  main;
     41 
     42 
     43 
     44         location / {
     45             root   web;
     46             index  index.html index.htm;
     47         }
     48 
     49 location ^~/proxy/html/{
     50 rewrite ^/proxy/html/(.*)$ /$1 break;
     51 #root proxy;
     52 proxy_pass http://localhost:81;
     53 }
     54         #error_page  404              /404.html;
     55 
     56         # redirect server error pages to the static page /50x.html
     57         #
     58         error_page   500 502 503 504  /50x.html;
     59         location = /50x.html {
     60             root   html;
     61         }
     62 
     63         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
     64         #
     65         #location ~ .php$ {
     66         #    proxy_pass   http://127.0.0.1;
     67         #}
     68 
     69         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
     70         #
     71         #location ~ .php$ {
     72         #    root           html;
     73         #    fastcgi_pass   127.0.0.1:9000;
     74         #    fastcgi_index  index.php;
     75         #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
     76         #    include        fastcgi_params;
     77         #}
     78 
     79         # deny access to .htaccess files, if Apache's document root
     80         # concurs with nginx's one
     81         #
     82         #location ~ /.ht {
     83         #    deny  all;
     84         #}
     85     }
     86 
     87 
     88     # another virtual host using mix of IP-, name-, and port-based configuration
     89     #
     90     #server {
     91     #    listen       8000;
     92     #    listen       somename:8080;
     93     #    server_name  somename  alias  another.alias;
     94 
     95     #    location / {
     96     #        root   html;
     97     #        index  index.html index.htm;
     98     #    }
     99     #}
    100 
    101 
    102     # HTTPS server
    103     #
    104     #server {
    105     #    listen       443 ssl;
    106     #    server_name  localhost;
    107 
    108     #    ssl_certificate      cert.pem;
    109     #    ssl_certificate_key  cert.key;
    110 
    111     #    ssl_session_cache    shared:SSL:1m;
    112     #    ssl_session_timeout  5m;
    113 
    114     #    ssl_ciphers  HIGH:!aNULL:!MD5;
    115     #    ssl_prefer_server_ciphers  on;
    116 
    117     #    location / {
    118     #        root   html;
    119     #        index  index.html index.htm;
    120     #    }
    121     #}
    122 
    123 }
  • 相关阅读:
    PDO扩展
    阿里云ECS VSFTP上传本地文件
    Nginx+lua_Nginx+GraphicsMagick来实现实时缩略图
    Mysql 5.6主从同步配置与解决方案
    windows安装配置mongodb及图形工具MongoVUE
    安装phpredis扩展以及phpRedisAdmin工具
    Redis安装配置以及开机启动
    CentOS安装Git服务器 Centos 6.5 + Git 1.7.1.0 + gitosis
    OpenStack 入门3
    Openstack 入门2
  • 原文地址:https://www.cnblogs.com/weiweictgu/p/6126090.html
Copyright © 2011-2022 走看看