AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-97

Jauder Ho's questions

Martin Hope
Jauder Ho
Asked: 2009-07-28 14:45:38 +0800 CST

仅用于 nginx 的静态配置?

  • 1

我试图为使用 try_files 的 nginx 获取仅静态配置,但遇到了一些问题。以下是我现在正在工作的内容(但不处理目录,显示索引等)我想看看我是否可以得到一个 try_files 工作的版本......

  server {
    listen 80;
    server_name foo.com;
    rewrite ^ http://www.foo.com$uri permanent;
  }

  # the server directive is nginx's virtual host directive.
  server {
    # port to listen on. Can also be set to an IP:PORT
    listen 80;

    # Set the charset
    charset utf-8;

    # Set the max size for file uploads to 10Mb
    client_max_body_size 10M;

    # sets the domain[s] that this vhost server requests for
    server_name www.foo.com; 

    # doc root
    root /var/www/foo.com;

    # vhost specific access log
    access_log  /var/log/nginx_access.log  main;


    # Set image format types to expire in a very long time
    location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
        access_log off;
        expires max;
    }

    # Set css and js to expire in a very long time
    location ~* ^.+\.(css|js)$ {
        access_log off;
        expires max;
    }

    location /blog {
     rewrite ^ http://blog.foo.com permanent; 
    }

    # Catchall for everything else
    location / {
      root /var/www/foo.com;
      access_log off;

      index index.html index.shtml;
      expires 1d;

      #try_files $uri $uri/;

      if (-f $request_filename) {
        break;
      }
    }

    location ~* ^/(pkg|rpms)/ {
      autoindex on;
    }

    error_page 500 502 503 504 /500.html;
    error_page 404 /404.html;

  }
web-server configuration nginx
  • 1 个回答
  • 3723 Views
Martin Hope
Jauder Ho
Asked: 2009-07-05 17:31:57 +0800 CST

如何让 nginx 从 www 重定向到非 www 域?

  • 9

假设我想从 www.example.com 重定向到 example.com,并且我想使用 nginx 来做到这一点。我环顾四周,没有看到任何好的文档,所以我想我会问并回答我自己的问题。

website web-server web-hosting web nginx
  • 5 个回答
  • 11121 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve