SSR项目
如果前端项目是服务器端渲染的SSR项目,则与普通的前端项目有很大不同,它不仅需要守护后端程序,还有前端静态资源的处理,如果是首页,还需要处理www
详细配置如下
upstream client { server 127.0.0.1:3002;}server{ listen 80; server_name www.xiaohuochai.cc xiaohuochai.cc; return 301 https://www.xiaohuochai.cc$request_uri;}server{ listen 443 http2; server_name www.xiaohuochai.cc xiaohuochai.cc; ssl on; ssl_certificate /home/blog/client/crt/www.xiaohuochai.cc.crt; ssl_certificate_key /home/blog/client/crt/www.xiaohuochai.cc.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; if ($host = 'xiaohuochai.cc'){ rewrite ^/(.*)$ http://www.xiaohuochai.cc/$1 permanent; } location / { expires 7d; add_header Content-Security-Policy "default-src 'self' https://static.xiaohuochai.site; connect-src https://api.xiaohuochai.cc; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://static.xiaohuochai.site ; img-src 'self' data: https://pic.xiaohuochai.site https://static.xiaohuochai.site; style-src 'self' 'unsafe-inline' https://static.xiaohuochai.site; frame-src https://demo.xiaohuochai.site https://xiaohuochai.site https://www.xiaohuochai.site;"; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forward-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Nginx-Proxy true; proxy_pass http://client; proxy_redirect off; }}
作者:小火柴的蓝色理想 来源:http://39sd.cn/2FAE2
【教你使用nginx部署网站教程】
推荐阅读
- 上虞,日本茶叶防霜冻系统投入使用
- 如何快速学会使用万能表?弄懂这8个功能是关键
- 茄子怎么做才好吃?教你简单家常做法,蒜香味浓郁,特别下饭
- 专家教你秋冬如何饮茶以及鉴别 收藏紫砂
- 上海|一次申请重复使用!上海“核酸码”明日起全市推广:做核酸更方便
- 电子消毒柜原理 电子消毒柜使用方法
- 臭氧消毒柜怎么样 臭氧消毒柜使用方法
- 专家教你高血压茶疗十法
- 出现节后综合症怎么办?教你收收过年放野了的心
- 专家教你如何用中药泡茶
