• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
深水是沉默
别自制压力,我们没有必要跟着时间走, 只需跟着心态和能力走 随缘 尽力 问心无愧,其他的,交给天。
博客园    首页    新随笔    联系   管理    订阅  订阅
linux ubuntu PHP之Nginx 配置

upstream www.xxxxxx.com {
  server localhost:9041;
}

 

#配置80端口重定向443端口

server {
  listen 80;
  server_name www.xxxxxx.com;#域名
  return 301 https://$server_name$request_uri;
}


server {
  listen 443 ssl;
  server_name www.xxxxxx.com;

  ssl on; #如果强制HTTPs访问,这行要打开
  ssl_certificate /ssl/1_www.xxxxxx.com_bundle.crt;
  ssl_certificate_key /ssl/2_www.xxxxxx.com.key;

  ssl_session_cache shared:SSL:1m;
  ssl_session_timeout 5m;

  # 指定密码为openssl支持的格式
  ssl_protocols SSLv2 SSLv3 TLSv1.2;

  ssl_ciphers HIGH:!aNULL:!MD5; # 密码加密方式
  ssl_prefer_server_ciphers on; # 依赖SSLv3和TLSv1协议的服务器密码将优先于客户端密码

  root /home/web/website/web;

  #关键代码

  location ~ .php$ {
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/run/php/php5.6-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
  }

  location / {
    index index.php index.html;
  }

  location ^~ /api/ {
    proxy_pass http://www.xxxxxx.com;
    client_max_body_size 1024m; #允许客户端请求的最大单文件字节数,人话:能上传多大文件
    client_body_buffer_size 6m; #缓冲区代理缓冲用户端请求的最大字节数,人话:一次能接受多
    proxy_connect_timeout 600; #nginx跟后端服务器连接超时时间(代理连接超时),这个看需求
    proxy_read_timeout 600; #连接成功后,后端服务器响应时间(代理接收超时),这个 同上
    rewrite "^/api/(.*)$" /$1 break;
  }

}

关键词:nginx,php,ubuntu,linux

 

posted on 2022-08-15 10:12  深水是沉默  阅读(143)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3