Access to font at 'http://zhaoheng.site:8443/css/fonts/fontawesome-webfont-b06871f281fee6b241d60582ae9369b9.ttf?v=4.7.0' from origin 'http://zhaoheng.site' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
本网的配置,核心如下:
upstream orchome { ip_hash; server 172.17.0.4:30093 weight=100; server 172.17.0.5:8093 weight=100; } server { listen 80; server_name orchome.com www.orchome.com; charset zh-CN; return 301 https://www.orchome.com$request_uri; } server { listen 443; server_name www.orchome.com; ssl on; ssl_certificate cert/a_www.pem; ssl_certificate_key cert/a_www.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; client_header_buffer_size 1m; large_client_header_buffers 4 10m; location / { proxy_pass http://orchome; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_intercept_errors on; } }
希望对你有帮助。
nginx配置信息
location / { proxy_pass http://zhaoheng.site:8443; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_intercept_errors on; add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true'; }
浏览器错误信息
Access to font at 'http://zhaoheng.site:8443/css/fonts/fontawesome-webfont-b06871f281fee6b241d60582ae9369b9.ttf?v=4.7.0' from origin 'http://zhaoheng.site' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
还是有点小问题,实在不行,就只能直接用80端口了。
你改成我上面的呀,你看我的是在
upstream
中。您这个应该是做负载均衡的吧。
前端
->
后端(内网地址),并且允许跨域访问。感谢您的回答
已经勉强的处理了
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; events { use epoll; worker_connections 51200; multi_accept on; } http { .... server_tokens off; access_log off; server { #SSL 访问端口号为 443 listen 443 ssl; #填写绑定证书的域名 server_name zhaoheng.site; index index.html index.htm index.php; root /www/wwwroot/zhaoheng.site; #证书文件名称 ssl_certificate 1_zhaoheng.site_bundle.crt; #私钥文件名称 ssl_certificate_key 2_zhaoheng.site.key; ssl_session_timeout 5m; #请按照以下协议配置 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; location / { #网站主页路径。此路径仅供参考,具体请您按照实际目录操作。 proxy_pass http://zhaoheng.site:8443; proxy_redirect off; proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Ssl on; } location ^~ /admin { rewrite /admin http://zhaoheng.site:8085/ permanent; } } server { listen 80; #填写绑定证书的域名 server_name zhaoheng.site; #把http的域名请求转成https return 301 https://$host$request_uri; } include /www/server/panel/vhost/nginx/*.conf; }
congratulation!
你的答案