当前位置:网站首页>Record of a cross domain problem
Record of a cross domain problem
2022-07-28 03:02:00 【Die hard audio and video】
Preface
Last project , For some reason , Need from https Access changed to http visit , There are cross domain problems in the transformation , Record... Here .
Project use nginx Acting as a reverse agent .
reform HTTP
When you visit the website browser, you will automatically jump to https, Need to put nginx http Redirect to https It's annotated
server {
listen 80;
listen [::]:80;
server_name server_name;
location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
root /usr/share/;
}
location = /.well-known/acme-challenge/ {
return 404;
}
# location / {
# return 301 https://$host$request_uri;
# }
}
So when we visit the browser , Will not automatically redirect us to https
Cross domain
It's changed to http Cross domain occurs when , The general solution is to nginx Add the following configuration
add_header 'Access-Control-Allow-Origin' '*';
But we also made the following mistakes
from origin ‘null’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
This error means that during the pre inspection , The browser does not allow redirection .
We see the MDN Definition of cross domain
Cross domain is actually a protection of browser access to different domains , Otherwise, anyone can access the resources of your domain name at will , It's also terrifying
In the case of not simple requests , Browsers usually publish one options Pre inspection request , To know if the server allows the actual request ." Pre inspection request “ Use , It can avoid the unexpected impact of cross domain requests on the user data of the server .
This design is very humanized , You can't add it directly to your business request ?
Back to our question , During the pre inspection , Redirection is not allowed , But my address is not redirected , Is something secretly giving me a layer of redirection behind my back ?
Request link : browser –》nginx–》 Business
Business is definitely not redirected , Browsers will not redirect for no reason , Then only NGINX 了
Open the browser console , In the network layer, we can see

Browser pre check found that the status code is 307, That must be redirection , And a point of attention ,Non-Authoriatative-Reason was HTTPS, We've already nginx Of https Instead of http, The domain name visited is also http, So there must be something wrong with this place
add_header Strict-Transport-Security "max-age=63072000" always;
The reason is mine nginx There is this configuration in the configuration , It means Inform the browser that all requests for the current domain name use https, That's why I ask for http, stay options When detecting , Automatically redirect me to https, and cros It is stipulated that before the pre inspection is completed , Redirection is not allowed , So it leads to the problem here
Remove this sentence , Or change it to the following form , restart nginx, Clean up browser cache , Or use traceless mode to access ,options There will be no redirection .
add_header Strict-Transport-Security max-age=0;

边栏推荐
- Pycharm 快速给整页全部相同名称修改的快捷键
- Skills in writing English IEEE papers
- Constant power wireless charging based on stm32
- tfx airflow 使用体验
- 数据湖:各模块组件
- [red team] att & CK - file hiding
- Docker advanced -redis cluster configuration in docker container
- 使用PyTorch的TensorBoard-可视化深度学习指标 | PyTorch系列(二十五)
- Docker高级篇-Docker容器内Redis集群配置
- Ah Han's story
猜你喜欢

CNN循环训练的解释 | PyTorch系列(二十二)

Superparameter adjustment and experiment - training depth neural network | pytorch series (26)

trivy【1】工具扫描运用

@The function of valid (cascade verification) and the explanation of common constraint annotations

app 自动化 环境搭建(一)

How to simply realize the function of menu dragging and sorting

JS event object 2 e.charcode character code e.keycode key code box moves up, down, left and right

Job 7.27 IO process

On the problem that sqli labs single quotation marks do not report errors
[email protected]注解使用"/>[email protected]注解使用
随机推荐
Center Based 3D object detection and tracking (centerpoint) paper notes
ROS的调试经验
【OpenGL】GLES20.glClear
New infrastructure helps the transformation and development of intelligent road transportation
Niuke-top101-bm340
Confusion matrix in CNN | pytorch series (XXIII)
Skills in writing English IEEE papers
LoRaWAN中的网关和chirpstack到底如何通信的?UDP?GRPC?MQTT?
[elm classification] classification of UCI data sets based on nuclear limit learning machine and limit learning machine, with matlab code
selenium+pytest+allure综合练习
Opengauss Developer Day 2022 sincerely invites you to visit the "database kernel SQL Engine sub forum" of Yunhe enmo
为什么登录时,明明使用的是数据库里已经有的账号信息,但依旧显示“用户不存在”?
小程序已获取数据库合集中的总记录、用户位置,怎么用Aggregate.geoNear将经纬度由近到远排列?
unordered_ The hash function of map and the storage mode of hash bucket
Redis aof日志持久化
TFX airflow experience
Promise object
[self growth website collection]
[leetcode] 13. linked list cycle · circular linked list
微服务架构统一安全认证设计与实践