Akiraka Akiraka
  • 首页
  • Linux
    • ELK
    • PHP
    • Shell
    • Nginx
    • Docker
      • Docker Compose
    • Centos
    • Ubuntu
    • Jenkins
  • Python
  • Mac OS
  • Windows
  • 大数据
    • Hadoop
    • CDH
    • Hive
    • Spark
    • ZooKeeper
  • 微服务
    • Kubernetes
    • Helm
  • Other
  • Quark
  • 首页
  • Linux
    • ELK
    • PHP
    • Shell
    • Nginx
    • Docker
      • Docker Compose
    • Centos
    • Ubuntu
    • Jenkins
  • Python
  • Mac OS
  • Windows
  • 大数据
    • Hadoop
    • CDH
    • Hive
    • Spark
    • ZooKeeper
  • 微服务
    • Kubernetes
    • Helm
  • Other
  • Quark
首页 › Linux › Nginx › Docker nginx和php分离配置

Docker nginx和php分离配置

Akiraka1年前
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
分享
Akiraka 站长
文章 121评论 10
相关文章
  • Kubernetes(k8s)helm 部署 Nginx Ingress
  • 使用 Docker 部署 LNMP 环境
  • Docker 使用官方镜像构建 nginx 容器
  • DockerFile 源码编译 Nginx 容器
  • 针对切割Nginx动态日志自动拉黑脚本
Akiraka
站长
本人擅长 Ai、Au、Fl、Ae、Pr、Ps 等软件的安装与卸载,精通 CSS、JavaScript、PHP、Python、Shell、Go 等单词的拼写,熟悉 Windows、Linux、Mac、Android、IOS 等系统的开关机!
121文章
10评论
47获赞
想找什么搜一下
文章聚合
MAC 安装Pyenv-virualemv
1年前
Kbernetes(k8s)helm 搭建 PV PVC 动态存储卷
12月前
Ubuntu 16.04 安装CDH 5.16.2
1年前
Kubernetes(k8s)helm 部署 RabbitMq 集群
11月前
shell 判断文件夹或文件是否存在
1年前
微信小程序
微信小程序
标签云
brew cdh centos cmd docker docker compose elasticsearch elk filebase filebeat gitlab grafana hadoop helm hive hue jdk jenkins k8s kibana kubernetes liniux linux logstash mac mikrotik mydumper mysql nfs nginx openssl oss php pip pyspark python RabbitMQ redis rocketmq shell Spark ubuntu windows ZooKeeper 容器编排
Copyright © 2019-2021 Akiraka. Designed by nicetheme. 沪18036911号