一、该问题的重现步骤是什么?
前后端部署nginx后,调用后端接口响应出现
2.
3.
二、你期待的结果是什么?实际看到的又是什么?
希望正常能够请求后端接口,现在提示 ”很抱歉,如果没有 JavaScript 支持,Saber 将不能正常工作。请启用浏览器的 JavaScript 然后继续。“
三、你正在使用的是什么产品,什么版本?在什么操作系统上?
四、请提供详细的错误堆栈信息,这很重要。
nginx.conf 配置如下
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
autoindex off;
server_tokens off;
client_max_body_size 64m;
#安全配置
add_header Content-Security-Policy "script-src 'self' 'unsafe-inline' 'unsafe-eval'" always;
add_header Referrer-Policy "same-origin" always;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Download-Options "noopen" always;
add_header X-Frame-Options "sameorigin" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "none" always;
add_header X-XSS-Protection "1; mode=block" always;
proxy_hide_header X-Powered-By;
proxy_hide_header Server;
fastcgi_hide_header X-Powered-By;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
proxy_connect_timeout 300;
proxy_read_timeout 300;
proxy_send_timeout 300;
keepalive_timeout 300;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#gzip on;
server {
listen 1888;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1;
}
location / {
root /usr/local/nginx/html/dist;
#try_files $uri $uri/ /index.html;
index index.html index.htm; # 处理前端路由刷新问题
#limit_conn conn_limit 10;
#limit_req zone=req_limit burst=20; #防止DDoS攻击
}
location ~ /\.{
deny all;
}
location ~* ^/(dir1|dir2|dir3)/ {
deny all;
return 404;
}
error_page 400 402 403 404 /40x.html;
# location = /index.html {
# root /html;
# internal;
#}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
server {
listen 8106;
server_name localhost;
#后端
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
add_header Content-Type "text/plain;charset=utf-8";
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST ,DELETE, PUT';
proxy_buffering off;
rewrite ^/api/(.*)$ /$1 break;
proxy_pass http://xxxx(为服务器ip):8106;
}
}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
五、若有更多详细信息,请在下面提供。
扫一扫访问 Blade技术社区 移动端