前言
公司有项目前端是用node.js进行服务器渲染,然后再返回给浏览器,进而解决单页面的SEO问题。项目部署的时候,使用Nginx反向代理Node.js。具体的步骤如下:
(Nginx、Node.js的安装和基本配置直接跳过)
首先我们要在nginx.cnf文件中的http节点打开下面的配置:
http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # 打开这一行的配置 include /etc/nginx/conf.d/*.conf; }