nginx配置解析域名

server
{
        listen 80;
        server_name www.xxx.com;
        index index.html index.htm index.php;
        root /home/wwwroot/default/目录;


        location ~ \.php{
            fastcgi_index  index.php;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_intercept_errors on;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
            fastcgi_split_path_info ^(.+\.php)(.*)$;     #添加
            fastcgi_param PATH_INFO $fastcgi_path_info;    #添加
        }


        location / {
            if (!-e $request_filename) {
                rewrite  ^(.*)$  /index.php?s=/$1  last;
                break;
            }
        }

        if (!-e $request_filename) {
            rewrite ^(/index\.php)?/(.*)$  /index.php/$2 break;
        }

        access_log  /home/wwwlogs/access.log;
    }

  

 

server {
        listen        80;
        server_name  friend.crm.com;
        root   "E:/wamp/lefujin_friends_crm/public";
                        location / {
           if (!-e $request_filename) {
                rewrite ^(.*)$ /index.php?s=$1 last;
                break;
           }
        }
        location ~* ^(.*)/[^/]+\.php$ {
                root E:/wamp/lefujin_friends_crm/public;
                include fastcgi_params;
                include        fastcgi.conf;
                fastcgi_split_path_info ^(.+\.php)(/.*)$;
                fastcgi_param  PATH_INFO        $fastcgi_path_info;

                set $scripts "$1/WEB-INF/entry.php";
                if (-f $request_filename) {
                        set $scripts $fastcgi_script_name;
                        break;
                }
                fastcgi_param  SCRIPT_FILENAME $document_root$scripts;

                fastcgi_pass 127.0.0.1:9000;

                #log_not_found  off;
        }
}

 

server {
    listen 87;
    server_name localhost;

    charset utf-8;

    #access_log  /var/log/nginx/access.log  main;
    #error_log  /var/log/nginx/error.log warn;

    root   /Users/mac059/project/backend-Service/public;

    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 6;
    gzip_types text/plain application/javascript application/x-javascript text/xml text/css;
    gzip_disable "MSIE [1-6]\.";
    gzip_vary on;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
          index  index.php index.html index.htm;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #fastcgi_pass unix:/run/php/php-fpm.sock;
    fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_param HTTP_X_FORWARDED_FOR '';
        fastcgi_param HTTP_X_REAL_IP '';
        fastcgi_param HTTP_CLIENT_IP '';
        fastcgi_param HTTP_PROXY '';
        include fastcgi_params;
    }

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css|csv)$
        {
                root /Users/mac059/project/backend-Service/public;
                expires 30d;
        }
}

 配置ssl

    server {
        listen       80;
        server_name   www.xxx.com;
    rewrite ^(.*)$  https://$host$1 permanent;  #http重定向到https
 
        location / {
            root /home/www/immortal-crm/public;   #项目根目录
            index  index.php index.html index.htm;
            if (!-e $request_filename) {
                rewrite ^(.*)$ /index.php$1 last;
           }
        }
        #error_page  404              /404.html;
 
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
 
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ ^.+\.php {
            root /home/www/immortal-crm/public;  #项目根目录
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
       }
 
    }
 
    # HTTPS server
    #
    server {
        # ssl使用443端口
        listen       443 ssl;
        # 证书绑定的域名
        server_name  www.xxx.com;
 
        ssl_certificate  证书pem;
        ssl_certificate_key  证书key;
 
        # 启用 SSL Session 缓存 
        ssl_session_cache    shared:SSL:1m;
        # 缓存SSL握手产生的参数和加密密钥的时长
        ssl_session_timeout  5m;
 
        # 使用的加密套件的类型
        ssl_ciphers  HIGH:!aNULL:!MD5;
        # 加密套件优先选择服务器的加密套件
        ssl_prefer_server_ciphers  on;
 
        location / {
            root /home/www/immortal-crm/public;
            index  index.php index.html index.htm;
                if (!-e $request_filename){
            rewrite  ^(.*)$  /index.php?s=$1  last;   break;
            }
        }
        location ~ ^.+\.php {
            root /home/www/immortal-crm/public;  #项目根目录
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
       }
        location ~* (runtime|application)/{
            return 403;
       }
}
 

 

posted @ 2021-11-03 18:00  -韩  阅读(1181)  评论(0编辑  收藏  举报