外網映射內網端口8080, 外網訪問使用端口8379;
nginx監聽8080和80端口
1 #user nobody; 2 worker_processes 4; 3 4 #error_log logs/error.log; 5 #error_log logs/error.log notice; 6 #error_log logs/error.log info; 7 8 pid logs/nginx.pid; 9 10 worker_rlimit_nofile 65535; 11 12 events { 13 use epoll; 14 worker_connections 65535; 15 } 16 17 18 http { 19 include mime.types; 20 default_type application/octet-stream; 21 22 #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 23 # '$status $body_bytes_sent "$http_referer" ' 24 # '"$http_user_agent" "$http_x_forwarded_for"'; 25 26 #access_log logs/access.log main; 27 28 gzip on; 29 gzip_min_length 1k; 30 gzip_buffers 16 64k; 31 gzip_http_version 1.1; 32 gzip_comp_level 4; 33 gzip_types text/plain text/css application/xml image/png; 34 gzip_vary on; 35 36 sendfile on; 37 38 tcp_nopush on; 39 tcp_nodelay on; 40 keepalive_timeout 120; 41 42 client_max_body_size 1024m; 43 44 server { 45 listen 8080; 46 server_name 192.168.7.85; 47 #charset koi8-r; 48 49 #access_log logs/host.access.log main; 50 51 index index.jsp; 52 53 location / { 54 proxy_redirect off; 55 index index.jsp; 56 proxy_pass http://localhost:8088; 57 proxy_set_header Host $host:8379; 58 proxy_set_header X-Real_IP $remote_addr; 59 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 60 } 61 62 location ^~ /upload/ { 63 proxy_redirect off; 64 expires 10d; 65 root /var/e_learning; 66 } 67 68 location ~*\.(gif|jpg|png|js|css)$ { 69 proxy_redirect off; 70 expires 10d; 71 proxy_pass http://localhost:8088; 72 proxy_set_header Host $host:8379; 73 proxy_set_header X-Real_IP $remote_addr; 74 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 75 } 76 } 77 server{ 78 listen 80; 79 server_name localhost; 80 index index.jsp; 81 location / { 82 index index.jsp; 83 proxy_pass http://localhost:8088; 84 proxy_set_header Host $host:$server_port; 85 proxy_set_header X-Real_IP $remote_addr; 86 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 87 } 88 #鎵€鏈変笂浼犵殑鏂囦歡鐨勮闂厤緗? 89 location ^~ /upload/ { 90 expires 10d; 91 root /var/e_learning; #澶氬彴WEB鏈嶅姟鍣ㄧ敤NFS鍋氬叡浜鐞?榛樿鍦板潃 92 } 93 location ~*\.(gif|jpg|png|js|css)$ { 94 expires 10d; 95 proxy_pass http://localhost:8088; 96 proxy_set_header Host $host:$server_port; 97 proxy_set_header X-Real_IP $remote_addr; 98 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 99 } 100 } 101 # another virtual host using mix of IP-, name-, and port-based configuration 102 # 103 #server { 104 # listen 8000; 105 # listen somename:8080; 106 # server_name somename alias another.alias; 107 108 # location / { 109 # root html; 110 # index index.html index.htm; 111 # } 112 #} 113 114 115 # HTTPS server 116 # 117 #server { 118 # listen 443 ssl; 119 # server_name localhost; 120 121 # ssl_certificate cert.pem; 122 # ssl_certificate_key cert.key; 123 124 # ssl_session_cache shared:SSL:1m; 125 # ssl_session_timeout 5m; 126 127 # ssl_ciphers HIGH:!aNULL:!MD5; 128 # ssl_prefer_server_ciphers on; 129 130 # location / { 131 # root html; 132 # index index.html index.htm; 133 # } 134 #} 135 136 } 137 rtmp { 138 server{ 139 listen 1935; 140 application vod { 141 play /var/e_learning/upload/resource; 142 on_play http://192.168.7.85/video/checkByNginx.html; 143 } 144 application test{ 145 play /var/e_learning/upload/; 146 } 147 } 148 }