首页 > 系统相关 >nginx 跨域配置

nginx 跨域配置

时间:2024-10-24 16:42:15浏览次数:1  
标签:Control 跨域 header 配置 Access nginx add Allow gzip

user www www;
worker_processes auto;
error_log /www/wwwlogs/nginx_error.log crit;
pid /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

stream {
log_format tcp_format '$time_local|$remote_addr|$protocol|$status|$bytes_sent|$bytes_received|$session_time|$upstream_addr|$upstream_bytes_sent|$upstream_bytes_received|$upstream_connect_time';

access_log /www/wwwlogs/tcp-access.log tcp_format;
error_log /www/wwwlogs/tcp-error.log;
include /www/server/panel/vhost/nginx/tcp/*.conf;
}

events
{
use epoll;
worker_connections 1024;
multi_accept on;
}

http
{
include mime.types;
#include luawaf.conf;

include proxy.conf;

default_type application/octet-stream;

server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;

sendfile on;
tcp_nopush on;

keepalive_timeout 60;

tcp_nodelay on;

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";

limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;

server_tokens off;
access_log off;

add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Blade-Requested-With,Blade-Auth,Host';

server
{
listen 8082;
server_name 124.223.143.212;
charset utf-8;

location /torch {
proxy_pass http://f..p.top:31084/torch/;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Blade-Requested-With,Blade-Auth,Host';


if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization,Blade-Requested-With,Blade-Auth,Host';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

}
}

 

标签:Control,跨域,header,配置,Access,nginx,add,Allow,gzip
From: https://www.cnblogs.com/myibm/p/18499898

相关文章

  • Keepalived+Nginx 高可用(主从模式)
     1.环境说明vipip操作系统nginx端口主从说明192.168.115.150192.168.115.148CentOSLinuxrelease7.6.1810(Core)8443主节点192.168.115.150192.168.115.149CentOSLinuxrelease7.6.1810(Core)8443从节点2台机器都需部署nginx和keealive服务,ngin......
  • logback配置模板
    <!--定义日志文件路径--><propertyname="LOG_PATH"value="${logPath:-default_log_path}"/><!--控制台输出--><appendername="CONSOLE"class="ConsoleAppender"><encoderclass="PatternLayoutE......
  • 使用跳板机在 PyCharm 中配置远程服务器的 Python 环境
    使用跳板机在PyCharm中配置远程服务器的Python环境在需要通过跳板机连接到远程服务器时,PyCharm提供了一些内置的方式,可以让你通过中间服务器访问远程机器上的Python解释器。本指南将介绍如何使用PyCharm通过跳板机连接,并在远程服务器上运行Python。前提条件PyCharm......
  • ssts-hospital-web-master项目实战记录五:环境配置
    记录时间:2024-10-24《.env.development》VITE_APP_ENV=development#VITE_APP_BASE_URL=/apiVITE_APP_BASE_URL=http://127.0.0.1:9000/VITE_APP_ADAPTERSERVICE_URL=http://127.0.0.1:9080/VITE_APP_TERMINALSERVICE_URL=http://localhost:8881/VITE_APP_EZWAREWEBSOCKET......
  • nginx总结
    使用auth_basic控制访问nginx代理的网站,直接访问如果需要添加安全性,如需要输入用户名+密码才能访问页面,可以通过nginx的auth_baisc配置来实现检查htpasswd一般nginx的安装之后会自带或者nginx容器镜像自带root@ea6255db9f51:/config/nginx/site-confs#htpasswdUsage:......
  • VRRP原理与配置
    1.简介什么是VRRP:VRRP(VirtualRouterRedundancyProtocol)是一种用于提高网络中路由器可用性的协议。它允许多个路由器共享一个虚拟IP地址,确保当一个路由器出现故障时,流量可以自动切换到其他路由器,从而提高网络的冗余性和稳定性。应用场景:常见于需要高可用性和冗余的网络......
  • 在Windows中,可以使用PowerShell来迁移打印机设置,以下是用于导出和导入打印机配置的Pow
    在Windows中,可以使用PowerShell来迁移打印机设置,以下是用于导出和导入打印机配置的PowerShell代码示例。导出打印机设置使用以下命令导出当前打印机设置到一个文件:powershellCopyCodeGet-Printer|Export-Clixml-Path"C:\path\to\exported_printers.xml"导入打印机设置......
  • Nginx的 MIME TYPE问题导致的mjs文件加载出错的问题解决
    .mjs文件:明确表示使用ES6模块系统(ECMAScriptModules)。 在服务器用Nginx部署前端项目后,出现下面这种问题Failedtoloadmodulescript:ExpectedaJavaScriptmodulescriptbuttheserverrespondedwithaMIMEtypeof"application/octet-stream".StrictMIMEt......
  • nginx 默认60超时需要修改的地址
    1、这个是转发的nginx的vhost模块的php,添加以下代码 ,如果没有,可以忽略location/{if($query_string~*"\.\./|\./"){return404;}proxy_read_timeout300s;#增加到5分钟proxy_connect_timeout300s;prox......
  • ElasticSearch配置文件解读
    elasticsearch的config文件夹里面有一个主配置文件:elasticsearch.yml是es的基本配置文件。下面主要讲解下elasticsearch.yml这个文件中可配置的东西。源文件#========================ElasticsearchConfiguration=========================##NOTE:Elasticsearchcom......