[关闭]
@tsingwong 2016-10-13T08:26:46.000000Z 字数 1241 阅读 1126

hexo 与 nginx

nginx hexo


最初安装的hexo之后,使用的是 hexo g 去发布站点,那个默认发布到 4000 端口,所以使用 nginx 去反向代理到 4000 端口。

  1. # /usr/local/nginx/nginx.conf
  2. server {
  3. listen 80;
  4. server_name www.tsingwong.cn;
  5. #charset koi8-r;
  6. #access_log logs/host.access.log main;
  7. # location / {
  8. # root html;
  9. # index index.html index.htm;
  10. # }
  11. ...

最初安装的hexo之后,使用的是 hexo g 去发布站点,那个默认发布到 4000 端口,所以使用 nginx 去反向代理到 4000 端口。

  1. # /usr/local/nginx/nginx.conf
  2. server {
  3. listen 80;
  4. server_name www.tsingwong.cn;
  5. #charset koi8-r;
  6. #access_log logs/host.access.log main;
  7. # location / {
  8. # root html;
  9. # index index.html index.htm;
  10. # }
  11. location / {
  12. proxy_pass http://127.0.0.1:4000/;
  13. proxy_redirect off;
  14. proxy_set_header X-Real-IP $remote_addr;
  15. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  16. }
  17. #error_page 404 /404.html;
  18. # redirect server error pages to the static page /50x.html
  19. #
  20. error_page 500 502 503 504 /50x.html;
  21. location = /50x.html {
  22. root html;
  23. }
  24. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  25. #
  26. #location ~ \.php$ {
  27. # proxy_pass http://127.0.0.1;
  28. #}
  29. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  30. #
  31. #location ~ \.php$ {
  32. # root html;
  33. # fastcgi_pass 127.0.0.1:9000;
  34. # fastcgi_index index.php;
  35. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  36. # include fastcgi_params;
  37. #}
  38. # deny access to .htaccess files, if Apache's document root
  39. # concurs with nginx's one
  40. #
  41. #location ~ /\.ht {
  42. # deny all;
  43. #}
  44. }

后来发现这种方法只适用于自己测试用,如果部署网站的话还是应该 部署静态站点

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注