日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux apache 跨域,解决nginx/apache静态资源跨域访问问题详解

發布時間:2024/9/27 linux 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux apache 跨域,解决nginx/apache静态资源跨域访问问题详解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. apache靜態資源跨域訪問

找到apache配置文件httpd.conf

找到這行

#LoadModule headers_module modules/mod_headers.so

把#注釋符去掉

LoadModule headers_module modules/mod_headers.so

目的是開啟apache頭信息自定義模塊

在獨立主機配置文件中新增header

Header set Access-Control-Allow-Origin *

例如:

ServerAdmin admin@example.com

DocumentRoot "****************"

ServerName www.jb51.com

Header set Access-Control-Allow-Origin *

ErrorLog "***********"

CustomLog "****************************" common

SetOutputFilter DEFLATE

Options FollowSymLinks ExecCGI

Require all granted

AllowOverride All

Order allow,deny

Allow from all

DirectoryIndex index.html index.php

ApacheCopy

意思是對這個域名的資源進行訪問時,添加一個頭信息

重啟apache

service httpd restart

2. nginx靜態資源允許跨域訪問

同理 找到相應域名配置文件

在server模塊中添加配置:

add_header ‘Access-Control-Allow-Origin' ‘*';

例:

server {

listen 80;

add_header 'Access-Control-Allow-Origin' '*';

location /Roboto/ {

root /home/images;

autoindex on;

}

}

nginx重載

./nginx -s reload

通過以上方法配置完后,再次跨域訪問靜態資源就沒有問題了

以上既是nginx/apache靜態資源允許跨域訪問解決方法

總結

以上是生活随笔為你收集整理的linux apache 跨域,解决nginx/apache静态资源跨域访问问题详解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。