- nginx 管理静态页面,然后将数据页面的请求转发到nodejs,为什么只能拿到index.html?
- 页面数据请求该如何转发到nodejs--8080端口应该不需要防火墙开放吧
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
rewrite ^(.*)$ https://$host$1 permanent;
}
server {
listen 443 ssl;
server_name ljwzz.xyz;
ssl_certificate 1.crt;
ssl_certificate_key 1.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html;
}
location /favicon.ico {
root html;
}
location ^~ /static/ {
root html/static;
}
# location / {
# proxy_pass http://127.0.0.1:8080/;
# }
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
浏览器错误()
网址/:1 GET https://网址/static/css/app.788ade4b8ad34482e3f85e0ee52745fb.css net::ERR_ABORTED
网址/:1 GET https://网址/static/js/manifest.2ae2e69a05c33dfc65f8.js net::ERR_ABORTED
网址/:1 GET https://网址/static/js/app.fba152483a9d7ae39f17.js net::ERR_ABORTED
网址/:1 GET https://网址/static/js/vendor.65142fefac425d6e5f53.js net::ERR_ABORTED
网址/:1 GET https://网址/static/js/app.fba152483a9d7ae39f17.js net::ERR_ABORTED
文件结构
.
|-- 50x.html
|-- index.html
`-- static
|-- css
| |-- app.788ade4b8ad34482e3f85e0ee52745fb.css
| `-- app.788ade4b8ad34482e3f85e0ee52745fb.css.map
|-- fonts
| `-- element-icons.6f0a763.ttf
`-- js
|-- app.fba152483a9d7ae39f17.js
|-- app.fba152483a9d7ae39f17.js.map
|-- manifest.2ae2e69a05c33dfc65f8.js
|-- manifest.2ae2e69a05c33dfc65f8.js.map
|-- vendor.65142fefac425d6e5f53.js
`-- vendor.65142fefac425d6e5f53.js.map
return 301 https://域名$request_uri;
就行。location /
里可能要加个try_files
指令。试试: