【问题标题】:How to use Nginx as a reverse proxy for a blog by configuring nginx.conf w a proxy_pass如何通过配置 nginx.conf w a proxy_pass 使用 Nginx 作为博客的反向代理
【发布时间】:2015-05-15 09:13:47
【问题描述】:

我正在努力让我在 mysite.com/blog 上的网站显示我的 tumblr 博客而不显示 tumblr URL。

我正在使用 NGINX 并由 nginx.conf 更新如下:

location /blog {
  proxy_set_header  X-Real-IP  $remote_addr;
  proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $http_host;
  proxy_redirect off;

  gzip on;
  gzip_min_length  1100;
  gzip_buffers     4 8k;
  gzip_proxied any;
  gzip_types  text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

  if (!-f $request_filename) {
    rewrite ^/blog$     /;
    rewrite ^/blog/(.*)$ /$1;
    proxy_pass http://denise-puchol.tumblr.com/;
    break;
  }
}

这是失败的,没有错误消息。有什么想法我在这里做错了吗?谢谢

【问题讨论】:

  • 你有没有想过这个问题?我有类似的事情正在努力完成。

标签: nginx reverse-proxy


【解决方案1】:

This nginx gist 可能有助于为您的 Tumblr 博客建立反向代理。 Definitely worthwhile to subfolder rather than subdomain your blog 用于 SEO 目的。

【讨论】:

  • 这对我有用。确保将 HTTPS 重定向到 HTTP,因为 tumblr 将通过 HTTP 加载其所有资源,从而导致浏览器混乱。
【解决方案2】:

仅使用自定义域名怎么样: http://www.tumblr.com/docs/en/custom_domains ?

您可能需要将您的 url 方案更改为 blog.mysite.com,但它的巨大优势是流量直接流向 tumblr 的服务器,而不是通过您的服务器代理。 如果您的博客收到大量流量,您的服务器可能会不堪重负。此外,攻击者可能会滥用您的代理对 tumblr 发起攻击,然后这些攻击似乎来自您的服务器。

【讨论】:

  • 我已经有了那个设置,它不利于 seo 的目的,真的很想把它作为 mysite.com/blog 工作......在 nginx.conf 上看到任何问题吗?谢谢
猜你喜欢
  • 2018-07-01
  • 2013-12-03
  • 2019-05-03
  • 2021-03-15
  • 1970-01-01
  • 2018-02-23
  • 2014-05-01
  • 1970-01-01
相关资源
最近更新 更多