配置Nginx多端口 , 播放音频,查看文本

user  oriontest;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
autoindex_localtime on;
charset utf-8,gbk;

    #gzip  on;
    upstream  tomcat-9 {
              server 127.0.0.1:8080;
        }

    server {
        listen       6090;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /home/oriontest/auto;
            autoindex on;
            autoindex_exact_size off;
            autoindex_localtime on;
        }

        #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   html;
        }


    }




    server {
        listen       80;
        #server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
            root /home/oriontest/tomcat-9/webapps/ROOT/download;
         location  /
        {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Accept-Encoding "none";
            proxy_redirect off;
            proxy_pass http://tomcat-9/;
            ssi on;
        }
location ~ .*\.(html|htm|txt|jpg|jpeg|bmp|png|ico|txt|js|css|pdf)$
             {
                  root /home/oriontest/tomcat-9/webapps/ROOT/download;
                  add_header Content-Type text/plain;
                   expires      7d;
               }


           location ~ .*\.(mp3|wav|mov|pcm|m4a)$ {
                add_header 'Access-Control-Allow-Origin' '*';
                add_header 'Access-Control-Allow-Credentials' 'true';
                add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
                root /home/oriontest/audio;
        }
        error_page   500 502 503 504  /50x.html;
    }


server {
        listen       81;
        #server_name  localhost;
        #        #charset koi8-r;
        #                #access_log  logs/host.access.log  main;
      root /home/oriontest/tomcat-9/webapps/ROOT/download;
         location  /
        {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Accept-Encoding "none";
            proxy_redirect off;
            proxy_pass http://tomcat-9/;
            ssi on;
        }

         location ~ .*\.(html|htm|txt|jpg|jpeg|bmp|png|ico|txt|js|css|pdf|json)$
             {
                  root /home/oriontest/pictures;
                  add_header Content-Type text/plain;
                   expires      7d;
               }
         }

server {
        listen       443;
        server_name  test.ainirobot.com;
        ssl                  on;
        ssl_certificate      /home/oriontest/nginx/conf/ssl/ainirobot.com.crt;
        ssl_certificate_key  /home/oriontest/nginx/conf/ssl/ainirobot.com.key;
        location / {
            proxy_pass http://127.0.0.1:8080;
        }
 
         
         }

 

你可能感兴趣的:(环境搭建)