Linux+apache cross-domain configuration

藏色散人
Release: 2019-08-05 14:18:09
forward
3388 people have browsed it

Linux+apache cross-domain configuration

#To understand cross-domain, you must first understand the same-origin policy. The Same Origin Policy is a very important security policy implemented on browsers for security reasons.

Related recommendations: [Linux video tutorial]

What is the same origin:

URL consists of protocol, domain name, port and path. If the protocol, domain name and port of two URLs are the same, it means that they have the same origin.

Same-origin policy:

The browser's same-origin policy restricts "documents" or scripts from different sources from reading or setting the current "document" certain properties.

Scripts loaded from one domain are not allowed to access document properties of another domain.

Edit apache configuration

Edit apache configuration file httpd.conf

Open extension

LoadModule headers_module modules/mod_headers.so
Copy after login

Add configuration

 AllowOverride None Header set Access-Control-Allow-Origin * //设置允许跨域域名 Header set Access-Control-Allow-Methods * //响应标头指定响应访问所述资源到时允许的一种或多种方法预检请求 Header set Access-Control-Allow-Headers content-type,authorization //响应报头在响应用于一个预检请求指示哪个HTTP标头将通过提供Access-Control-Expose-Headers使实际的请求时。 Header set Access-Control-Max-Age '1728000'//响应 header 指示多长时间的结果预检请求(即包含在所述信息Access-Control-Allow-Methods和Access-Control-Allow-Headers的 headers )可以被缓存。 Header set Content-Security-Policy upgrade-insecure-requests 
Copy after login

You can understand the http protocol by yourself for detailed configuration

Restart apapche

service httpd restart

The above is the detailed content of Linux+apache cross-domain configuration. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!