nginx、apache修改set-cookie,实现cookie跨域
3:打开终端命令行,先通过 nginx -V 命令获取配置文件的所有模块数据,然后在数据最后追加 --add-module=/www/server/nginx/src/headers-more-nginx-module-0.33。2:解压到服务器某目录下(最好和其他模块放一起):tar -zxvf headers-more-nginx-module-0.33.tar.gz。1:下载安装header
nginx、apache修改set-cookie,实现cookie跨域:
nginx
方案1:利用headers-more-nginx-module模块(复杂)
1:下载安装headers-more-nginx-module模块文件
https://github.com/openresty/headers-more-nginx-module/tags
2:解压到服务器某目录下(最好和其他模块放一起):tar -zxvf headers-more-nginx-module-0.33.tar.gz
3:打开终端命令行,先通过 nginx -V 命令获取配置文件的所有模块数据,然后在数据最后追加 --add-module=/www/server/nginx/src/headers-more-nginx-module-0.33
4:./configure 命令添加步骤3拼接的模块配置数据,例如:./configure --user=www --group=www --prefix=/www/server/nginx --add-module=/www/server/nginx/src/ngx_devel_kit --add-module=/www/server/nginx/src/lua_nginx_module --add-module=/www/server/nginx/src/ngx_cache_purge --add-module=/www/server/nginx/src/nginx-sticky-module --with-openssl=/www/server/nginx/src/openssl --with-pcre=pcre-8.43 --with-http_v2_module --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_stub_status_module --with-http_ssl_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-ipv6 --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --add-module=/www/server/nginx/src/ngx_http_substitutions_filter_module-master --with-ld-opt=-Wl,-E --with-cc-opt=-Wno-error --with-ld-opt=-ljemalloc --with-http_dav_module --add-module=/www/server/nginx/src/nginx-dav-ext-module --add-module=/www/server/nginx/src/headers-more-nginx-module-0.33
5:make & make install 重新编译一下
6:在 nginx.conf或者伪静态中新增 more_set_headers “Set-Cookie:$sent_http_set_cookie; Secure;SameSite=None”; 即可
location ~* (runtime|application)/{
return 403;
}
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
more_set_headers "Set-Cookie:$sent_http_set_cookie; Secure;SameSite=None";
7:重启nginx服务器
方案2:利用add_header(简单)
1、在 nginx.conf或者伪静态中新增 add_header Set-Cookie “$sent_http_set_cookie; Secure;SameSite=None”; 即可
location ~* (runtime|application)/{
return 403;
}
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
add_header Set-Cookie "$sent_http_set_cookie; Secure;SameSite=None";
apache
方案1:Header always edit
1、在httpd.conf或者伪静态.htaccess中新增 Header always edit Set-Cookie ^(.*)$ $1;Secure;SameSite=None; 即可。重点要加always
Header always edit Set-Cookie ^(.*)$ $1;Secure;SameSite=None;
更多推荐
所有评论(0)