Nginx代理外网映射

外网映射内网端口8080, 外网访问使用端口8379;

nginx监听8080和80端口

 #user  nobody;
worker_processes ; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; pid logs/nginx.pid; worker_rlimit_nofile ; events {
use epoll;
worker_connections ;
} 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; gzip on;
gzip_min_length 1k;
gzip_buffers 64k;
gzip_http_version 1.1;
gzip_comp_level ;
gzip_types text/plain text/css application/xml image/png;
gzip_vary on; sendfile on; tcp_nopush on;
tcp_nodelay on;
keepalive_timeout ; client_max_body_size 1024m; server {
listen ;
server_name 192.168.7.85;
#charset koi8-r; #access_log logs/host.access.log main; index index.jsp; location / {
proxy_redirect off;
index index.jsp;
proxy_pass http://localhost:8088;
proxy_set_header Host $host:;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
} location ^~ /upload/ {
proxy_redirect off;
expires 10d;
root /var/e_learning;
} location ~*\.(gif|jpg|png|js|css)$ {
proxy_redirect off;
expires 10d;
proxy_pass http://localhost:8088;
proxy_set_header Host $host:;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server{
listen ;
server_name localhost;
index index.jsp;
location / {
index index.jsp;
proxy_pass http://localhost:8088;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#鎵€鏈変笂浼犵殑鏂囦欢鐨勮闂厤缃?
location ^~ /upload/ {
expires 10d;
root /var/e_learning; #澶氬彴WEB鏈嶅姟鍣ㄧ敤NFS鍋氬叡浜鐞?榛樿鍦板潃
}
location ~*\.(gif|jpg|png|js|css)$ {
expires 10d;
proxy_pass http://localhost:8088;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen ;
# listen somename:;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }
rtmp {
server{
listen ;
application vod {
play /var/e_learning/upload/resource;
on_play http://192.168.7.85/video/checkByNginx.html;
}
application test{
play /var/e_learning/upload/;
}
}
}
上一篇:angular 动态取到的html片段 在页面的展示


下一篇:Mac VMware fusion nat 外网映射