国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Nginx > 正文

利用nginx解決cookie跨域訪問的方法

2024-08-30 12:22:26
字體:
來源:轉載
供稿:網友
本篇文章主要介紹了利用nginx解決cookie跨域訪問的方法,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

一、寫在前面

最近需要把阿里云上的四臺服務器的項目遷移到客戶提供的新的項目中,原來的四臺服務器中用到了一級域名和二級域名。比如aaa.abc.com 和bbb.abc.com 和ccc.abc.com。其中aaa.abc.com登錄,通過把cookie中的信息setDomain給.abc.com。其他系統可以共享這個cookie。但是新的四臺服務器中并沒有申請域名,只有四個ip:

192.168.0.1    單點登錄服務器

192.168.0.2

192.168.0.3

192.168.0.4

因為每臺服務器有兩個項目,都用到單點登錄,所以通過修改新的共享登錄方式花費時間太多,于是在網上搜cookie的跨域登錄,嘗試了下,在192.168.0.1    單點登錄服務器中多次setDomain分別給2、3、4服務器,結果不理想,因為瀏覽器不允許。后來無意中看到nginx可以通過欺騙的方式共享cookie。于是想到原來公司部署nginx還有這層用法。

二、原來的nginx配置

先說下nginx的安裝,這個網上都有很多教程,不在贅述,我是參照于在Linux里安裝、啟動nginx。需要注意的是./configure后面的各種with,我在配置啟動過程遇到了一些問題:

nginx: [emerg] unknown directive "aio" in

加上--with-file-aio 

復制代碼 代碼如下:Starting nginx: nginx: [emerg] the INET6 sockets are not supported on this platform in “[::]:80” of the

在后面加上--with-ipv6好使。

安裝完成后。主要是nginx.conf的配置

原來服務器的配置nginx.conf:

# For more information on configuration, see:#  * Official English Documentation: http://nginx.org/en/docs/#  * Official Russian Documentation: http://nginx.org/ru/docs/user root;worker_processes 2;worker_cpu_affinity 1000 0100;error_log logs/error.log;pid logs/nginx.pid;events {  worker_connections 2048;}http {  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;  gzip on;  gzip_min_length 1000;  gzip_buffers   4 8k;  gzip_types    text/plain application/javascript application/x-javascript text/css application/xml;  client_max_body_size 8M;  client_body_buffer_size 128k;  sendfile      on;  tcp_nopush     on;  tcp_nodelay     on;  keepalive_timeout  65;  types_hash_max_size 2048;  include       mime.types;  default_type    application/octet-stream;  connection_pool_size 512;  aio on;  open_file_cache max=1000 inactive=20s;  # Load modular configuration files from the /etc/nginx/conf.d directory.  # See http://nginx.org/en/docs/ngx_core_module.html#include  # for more information.  #  主要配置在這里,nginx.conf配置都是一樣  include /usr/local/nginx/conf/conf.d/*.conf;  server {    listen    80 default_server;    listen [::]:80 ipv6only=on default_server;    server_name _;    root     html;    # Load configuration files for the default server block.    include /usr/local/nginx/conf/default.d/*.conf;    location / {    }    error_page 404 /404.html;      location = /40x.html {    }    error_page 500 502 503 504 /50x.html;      location = /50x.html {    }  }}
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 容城县| 广南县| 平安县| 卓资县| 万载县| 福泉市| 博白县| 鹰潭市| 宜州市| 洱源县| 高平市| 临汾市| 黄浦区| 岑巩县| 禹城市| 马公市| 西和县| 清涧县| 咸宁市| 孝感市| 湖州市| 驻马店市| 余江县| 常德市| 台湾省| 海林市| 当阳市| 深泽县| 敖汉旗| 垦利县| 江西省| 岳阳市| 金坛市| 汨罗市| 额济纳旗| 定兴县| 宝清县| 乐业县| 都匀市| 措勤县| 黄石市|