nginx php 配置

//集群

upstream payOrderServer {

    server 127.0.0.1:7600;

    server 127.0.0.1:7601;

    server 127.0.0.1:7602;

    server 127.0.0.1:7603;

}

//转发强制https

server{

    listen      80;

    server_name  xinpa.lylck.com;

    rewrite ^(.*)$  https://$host$1 permanent;

}

server {

    #listen      80;

    listen      443 ssl;

    #server_name  locahost;

    server_name  xinpa.lylck.com;

    ssl_certificate      conf.d/3132007_xinpa.lylck.com.pem;

    ssl_certificate_key  conf.d/3132007_xinpa.lylck.com.key;

    ssl_session_cache    shared:SSL:1m;

    ssl_session_timeout  5m;

    ssl_ciphers  HIGH:!aNULL:!MD5;

    ssl_prefer_server_ciphers  on;

    #charset koi8-r;

    #access_log  /var/log/nginx/host.access.log  main;

    proxy_set_header Host $host;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

#    location / {

#        #root  /usr/share/nginx/html;

#              root  /data/www/public;

#        index index.php index.html index.htm;

#    }

    location / {

        # First attempt to serve request as file, then

        # as directory, then fall back to displaying a 404.

        root  /data/www/public;

        index index.php index.html index.htm;

        if (!-e $request_filename) {

            rewrite  ^(.*)$  /index.php?s=/$1  last;

            break;

          }

    }

    location /starpay/ {

        proxy_pass https://payOrderServer;

    }

    location /poiusf/ {

      # if (!-e $request_filename){

      #        rewrite /poiusf/(.*)$ /poiusf.php/$1 last;

      #        #rewrite ^(.*)$  /poiusf.php?s=/$1  last;

      #    }

      proxy_pass  http://121.40.169.134/poiusf.php;

    }

    location /usuetr/ {

      # if (!-e $request_filename){

      #        rewrite /poiusf/(.*)$ /poiusf.php/$1 last;

      #        #rewrite ^(.*)$  /poiusf.php?s=/$1  last;

}

server{

    listen      80;

    server_name  xinpa.lylck.com;

    rewrite ^(.*)$  https://$host$1 permanent;

}

server {

    #listen      80;

    listen      443 ssl;

    #server_name  locahost;

    server_name  xinpa.lylck.com;

    ssl_certificate      conf.d/3132007_xinpa.lylck.com.pem;

    ssl_certificate_key  conf.d/3132007_xinpa.lylck.com.key;

    ssl_session_cache    shared:SSL:1m;

    ssl_session_timeout  5m;

    ssl_ciphers  HIGH:!aNULL:!MD5;

    ssl_prefer_server_ciphers  on;

    #charset koi8-r;

    #access_log  /var/log/nginx/host.access.log  main;

    proxy_set_header Host $host;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

#    location / {

#        #root  /usr/share/nginx/html;

#              root  /data/www/public;

#        index index.php index.html index.htm;

#    }

    location / {

        # First attempt to serve request as file, then

        # as directory, then fall back to displaying a 404.

        root  /data/www/public;

        index index.php index.html index.htm;

        if (!-e $request_filename) {

            rewrite  ^(.*)$  /index.php?s=/$1  last;

            break;

          }

    }

    location /starpay/ {

        proxy_pass https://payOrderServer;

    }

    location /poiusf/ {

      # if (!-e $request_filename){

      #        rewrite /poiusf/(.*)$ /poiusf.php/$1 last;

      #        #rewrite ^(.*)$  /poiusf.php?s=/$1  last;

      #    }

      proxy_pass  http://121.40.169.134/poiusf.php;

    }

    location /usuetr/ {

      # if (!-e $request_filename){

      #        rewrite /poiusf/(.*)$ /poiusf.php/$1 last;

      #        #rewrite ^(.*)$  /poiusf.php?s=/$1  last;

      #    }

      proxy_pass  http://121.40.169.134/usuetr.php;

    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html

    #

    error_page  500 502 503 504  /50x.html;

    location = /50x.html {

        root  /usr/share/nginx/html;

    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80

    #

    #location ~ \.php$ {

    #    proxy_pass  http://127.0.0.1;

    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    #

    location ~ \.php(.*)$ {

        root          /data/www/public;

        fastcgi_pass  127.0.0.1:9000;

        fastcgi_index  index.php;

        fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;

        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

        fastcgi_param  PATH_INFO  $fastcgi_path_info;

        fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;

        include        fastcgi_params;

  }

    # deny access to .htaccess files, if Apache's document root

    # concurs with nginx's one

    #

    #location ~ /\.ht {

    #    deny  all;

    #}

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Nginx简介 解决基于进程模型产生的C10K问题,请求时即使无状态连接如web服务都无法达到并发响应量级一万的现...
    魏镇坪阅读 6,298评论 0 9
  • 这篇是Nginx安装配置PHP(FastCGI)环境的教程。Nginx不支持对外部程序的直接调用或者解析,所有的外...
    SkTj阅读 8,292评论 2 20
  • nginx重写规则 nginx rewrite 正则表达式匹配 大小写匹配 ~ 为区分大小写匹配 ~* 为不区分大...
    桖辶殇阅读 10,896评论 0 2
  • 首先去阿里云的ca证书下载你自己的证书文件,没有的就买。下载的时候注意下载对应的,nginx下载nginx的。ap...
    Smallzz阅读 5,342评论 0 2
  • 大多数 Nginx 新手都会频繁遇到这样一个困惑,那就是当同一个location配置块使用了多个 Nginx 模块...
    SkTj阅读 12,387评论 0 12