ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

nginx配置文件

2022-01-05 20:36:08  阅读:193  来源: 互联网

标签:index 配置文件 header nginx html proxy fastcgi location


nginx配置文件

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
client_max_body_size 100m;  
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

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

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

server {
	listen       8092; 
	server_name tea.lv.com:8092;
	root   /www/wwwroot/product;
	index  index.htm index.html;
	add_header 'Access-Control-Allow-Origin' '*';
	add_header 'Access-Control-Allow-Credentials' 'true';
	add_header Cache-Control private;
	add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
	add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
	
	location / {
	     root  /www/wwwroot/product;
                    try_files $uri $uri/ /index.html last;
                    index index.html;
		
	}
	# 代理服务端接口
	location /api {
		rewrite ^/api/(.*)$ /$1 break;
		if ($request_method = 'OPTIONS') {
			add_header Access-Control-Allow-Origin *;
			add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,PATCH,OPTIONS;
			return 200;
		}
		proxy_pass http://xx.xxx.xx.xxx:8099;   #将真正的请求代理到API 服务地址
	}
	
	location /loginForm {
		rewrite ^/loginForm/(.*)$ /$1 break;
		if ($request_method = 'OPTIONS') {
			add_header Access-Control-Allow-Origin *;
			add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,PATCH,OPTIONS;
			return 200;
		}
		proxy_pass http://xx.xxx.xx.xxx:8097;   #将真正的请求代理到API 服务地址
	}


	location /apilogin {
		rewrite ^/apilogin/(.*)$ /$1 break;
		if ($request_method = 'OPTIONS') {
			add_header Access-Control-Allow-Origin *;
			add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,PATCH,OPTIONS;
			return 200;
		}
		proxy_pass http://xx.xxx.xx.xxx:8097;   #将真正的请求代理到API 服务地址
	}
	}	


server {
       listen       8093;
        server_name  register.lv.com;
        root /www/wwwroot/register;
index index.php index.html index.htm;
location / {
if ( -f $request_filename) {
       break;
   }
   if ( !-e $request_filename) {
       rewrite ^(.*)$ /index.php/$1 last;
       break;
   }
        try_files $uri $uri/ /index.php?$query_string;
    }
location ~ \.php {
        root /www/wwwroot/register;
        fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param  PATH_INFO $fastcgi_path_info;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name;
        # fastcgi_param SCRIPT_FILENAME /home/wwwroot/qinziheng/$fastcgi_script_name;
        include fastcgi_params;
    }

      # location / {
        # }

        location /api {            
             proxy_pass http://localhost:10010/;
             proxy_redirect default;
             proxy_set_header Host $host;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

server {
       listen       8094;
        server_name  ocr.lv.com;
        root /www/wwwroot/ocr;
index index.php index.html index.htm;
location / {
if ( -f $request_filename) {
       break;
   }
   if ( !-e $request_filename) {
       rewrite ^(.*)$ /index.php/$1 last;
       break;
   }
        try_files $uri $uri/ /index.php?$query_string;
    }
location ~ \.php {
        root /www/wwwroot/ocr;
        fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param  PATH_INFO $fastcgi_path_info;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name;
        # fastcgi_param SCRIPT_FILENAME /home/wwwroot/qinziheng/$fastcgi_script_name;
        include fastcgi_params;
    }

      # location / {
        # }

        location /api {            
             proxy_pass http://localhost:10010/;
             proxy_redirect default;
             proxy_set_header Host $host;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }


server {
       listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  zydngw.zhiyundongneng.com;
        root         /www/wwwroot/zydngw.zhiyundongneng.com;
index index.php index.html index.htm;
location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }
location ~ \.php$ {
        root /www/wwwroot/zydngw.zhiyundongneng.com;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name;
        # fastcgi_param SCRIPT_FILENAME /home/wwwroot/qinziheng/$fastcgi_script_name;
        include fastcgi_params;
    }

        # location / {
        # }

        location /api {            
             proxy_pass http://localhost:10010/;
             proxy_redirect default;
             proxy_set_header Host $host;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }





# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers PROFILE=SYSTEM;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }
}

标签:index,配置文件,header,nginx,html,proxy,fastcgi,location
来源: https://blog.csdn.net/qq_44255146/article/details/122331269

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有