Get the App
SLTechnology News&Howtos  ›  Servers  › 

The method of cross-domain configuration of Linux+apache

Shulou Source: shulou.com Published: 2022-06-02 00:31:04 11月27日 Update

This article shares with you about the methods of cross-domain configuration of Linux+apache. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

To understand cross-domain, you must first understand the same origin policy. Homologous policy is a very important security policy implemented in browsers for security considerations.

What is homologous:

URL consists of protocols, domain names, ports, and paths. If the protocols, domain names and ports of two URL are the same, they are of the same origin.

Homologous policy:

The same origin policy of the browser restricts "document" or scripts from different sources to read or set certain properties on the current "document".

Scripts loaded from one domain do not allow access to the document properties of another domain.

Edit apache configuration

Edit apache profile httpd.conf

Open extension

LoadModule headers_module modules/mod_headers.so

Increase configuration

The AllowOverride NoneHeader set Access-Control-Allow-Origin * / setting allows cross-domain domain Header set Access-Control-Allow-Methods * / / response headers to specify one or more methods allowed in response to access to the resource. The precheck request Header set Access-Control-Allow-Headers content-type,authorization / / response header indicates which HTTP header will make the actual request by providing Access-Control-Expose-Headers in response to a precheck request. The Header set Access-Control-Max-Age '1728000 response header indicates how long the result pre-check request (i.e. the headers contained in the information Access-Control-Allow-Methods and Access-Control-Allow-Headers) can be cached. Header set Content-Security-Policy upgrade-insecure-requests

You can learn about http protocol for detailed configuration.

Restart apapche

Service httpd restart

Thank you for reading! So much for sharing the method of cross-domain configuration of Linux+apache. I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.

Tags: Homology configuration policy method domain name security content properties instructions more browser port script header browsing good practical same important two Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Xiaomi macOS Shulou Technology MySQL