nginx配置示例

在生产环境,建议使用https/wss,这个是小苹果IM产品在生产环境下的nginx配置示例,可以参考使用,注意替换域名,证书和ip


worker_processes  1;
events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }

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

    }

	  server{
		listen 80;
		server_name  api.xxxx.com; 
		location /
		{
			proxy_pass http://127.0.0.1:8092;
			proxy_redirect off;
			proxy_set_header Host   $host;
			proxy_set_header X-Real-IP      $remote_addr;
			client_max_body_size 100m;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		}
			
	}


	  server{
		listen 80;
		server_name  im.xxxx.com; 
		location /
		{
			proxy_pass http://127.0.0.1:8080;
			proxy_redirect off;
			proxy_set_header Host   $host;
			proxy_set_header X-Real-IP      $remote_addr;
			client_max_body_size 100m;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		}
			
	}




	    server{
		listen 80;
		server_name  seo.xxxx.com; 
		  charset utf-8;
		
		    location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|swf|flv|json|apk|woff|ttf)$ {
        root /opt/admin/dist;
        index index.html;
		if (!-e $request_filename) {
				rewrite ^(.*)$ /index.html?s=$1 last;
				break;
			} 
    }
	
location /
    {
        proxy_pass http://127.0.0.1:19981;
        proxy_redirect off;
        proxy_set_header Host   $host;
        proxy_set_header X-Real-IP      $remote_addr;
		client_max_body_size 100m;
		charset utf-8;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
		
	}
	
	server{
		listen 80;
		server_name  web.xxxx.com; 
		location /
		{
			proxy_pass http://127.0.0.1:5000;
			proxy_redirect off;
			proxy_set_header Host   $host;
			proxy_set_header X-Real-IP      $remote_addr;
			client_max_body_size 100m;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		}
			
	}
	

	server
{
    listen 80;
    server_name   file.xxxx.com;
    charset utf-8;
    access_log  logs/file.chat.club.access.log ;
     root /opt/resources;
}
}