[英]apache cross domain configuration
I am trying to setup this application on my server openspeedtest.com self-hosted app they provided Nginx configuration. 我试图在他们提供Nginx配置的服务器openspeedtest.com自托管应用上设置此应用。 how can i make this work on my apache shared hosting server? 如何在apache共享托管服务器上进行此工作?
fastcgi_read_timeout 360;
client_max_body_size 2000M;
location / {
if ($http_origin) {
add_header 'Access-Control-Allow-Origin' 'http://openspeedtest.com';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
}
if ($request_method = OPTIONS ) {
add_header Access-Control-Allow-Credentials "true";
add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With';
add_header Access-Control-Allow-Origin "http://openspeedtest.com";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
return 204;
}
}
Add this to your server! 将此添加到您的服务器!
Setting CORS (cross-origin resource sharing) on Apache. 在Apache上设置CORS(跨域资源共享)。 Create .htacess file with this config. 使用此配置创建.htacess文件。
# Always set these headers.
Header always set Access-Control-Allow-Origin "http://openspeedtest.com"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
#Don't forget to activate the apache module headers a2enmod headers
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.