Akiraka Akiraka
  • Home
  • Linux
    • ELK
    • PHP
    • Shell
    • Nginx
    • Docker
      • Docker Compose
    • Centos
    • Ubuntu
    • Jenkins
  • Python
  • Mac OS
  • Windows
  • Big Data
    • Hadoop
    • CDH
    • Hive
    • Spark
    • ZooKeeper
  • K8S
    • Kubernetes
    • Helm
  • Other
  • Quark
  • Contribute
  • Home
  • Linux
    • ELK
    • PHP
    • Shell
    • Nginx
    • Docker
      • Docker Compose
    • Centos
    • Ubuntu
    • Jenkins
  • Python
  • Mac OS
  • Windows
  • Big Data
    • Hadoop
    • CDH
    • Hive
    • Spark
    • ZooKeeper
  • K8S
    • Kubernetes
    • Helm
  • Other
  • Quark
  • Contribute
首页 Linux Nginx Docker nginx和php分离配置

Docker nginx和php分离配置

Akiraka 2年前
server {
  listen 80;
  server_name test.akiraka.net;
  index index.html index.htm index.php;
  root $webroot;
  set $webroot '/data/wwwroot/test.akiraka.net';
  access_log /data/wwwlogs/test.akiraka.net_nginx.log combined;

  include /usr/local/nginx/conf/rewrite/wordpress.conf;

  location ~ [^/]\.php(/|$) {
    # oneinstack有fastcgi.conf,不是请屏蔽
    include fastcgi.conf;
    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_pass php:9000;
    #fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_param SCRIPT_FILENAME $webroot$fastcgi_script_name;
  }
  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
    expires 30d;
    access_log off;
  }
  location ~ .*\.(js|css)?$ {
    expires 7d;
    access_log off;
  }
  location ~ /\.ht {
    deny all;
  }
}

如果Docker nginx和php做分离,nginx做配置必须要指定php的项目路径,而不是指定nginx下的项目路径,不然会找不到文件。也就是说nginx只是处理请求,php负责解析请求返回结果给nginx,那么项目文件就应该在php容器下。

server {
  listen 443 ssl http2;
  ssl_certificate /usr/local/nginx/conf/ssl/cloud.akiraka.net.pem;
  ssl_certificate_key /usr/local/nginx/conf/ssl/cloud.akiraka.net.key;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
  ssl_prefer_server_ciphers on;
  ssl_session_timeout 10m;
  ssl_session_cache builtin:1000 shared:SSL:10m;
  ssl_buffer_size 1400;
  add_header Strict-Transport-Security max-age=15768000;
  ssl_stapling on;
  ssl_stapling_verify on;
  root $webroot;
  set $webroot '/data/wwwroot/cloud.akiraka.net';
  server_name cloud.akiraka.net;
  access_log /data/wwwlogs/test.akiraka.net_nginx.log combined;
  if ($ssl_protocol = "") { return 301 https://$host$request_uri; }

  #include /usr/local/nginx/conf/rewrite/wordpress.conf;

  location ~ [^/]\.php(/|$) {
    # oneinstack有fastcgi.conf,不是请屏蔽
    include fastcgi.conf;
    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_pass php:9000;
    #fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_param SCRIPT_FILENAME $webroot$fastcgi_script_name;
  }
  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
    expires 30d;
    access_log off;
  }
  location ~ .*\.(js|css)?$ {
    expires 7d;
    access_log off;
  }
  location ~ /\.ht {
    deny all;
  }
}
#nginx
0
猜你喜欢
  • KeyCloak 身份验证 Nginx 502网关错误
  • 密码保护:Kubernetes中容器Nginx动态解析
  • Kubernetes(k8s)helm 部署 Nginx Ingress
  • 使用 Docker 部署 LNMP 环境
  • Docker 使用官方镜像构建 nginx 容器
Akiraka
站长
本人擅长 Ai、Au、Fl、Ae、Pr、Ps 等软件的安装与卸载,精通 CSS、JavaScript、PHP、Python、Shell、Go 等单词的拼写,熟悉 Windows、Linux、Mac、Android、IOS 等系统的开关机!
160
文章
24
评论
73
获赞
Popular Articles
TOP1
Kubernetes(k8s)Helm 部署 EFK 集群
2年前
TOP2
Kubernetes(k8s)helm 搭建 prometheus + Grafana 监控
2年前
TOP3
Container 命令ctr、crictl 命令使用说明
11月前
TOP4
Kubernetes(k8s)Helm 部署 Jenkins 持续化集成部署
2年前
TOP5
Helm 部署 Loki 日志聚合
2年前
Related Articles
Docker Nginx反向代理支持websocket
2年前
KeyCloak 身份验证 Nginx 502网关错误
3月前
密码保护:Kubernetes中容器Nginx动态解析
1年前
使用 Docker 部署 LNMP 环境
2年前
Docker 使用官方镜像构建 nginx 容器
2年前
Copyright © 2019-2022 Akiraka. 沪18036911号