#user nobody; 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; #gzip on; upstream appservice { server localhost:8080; } upstream oauth2 { server localhost:8081; } upstream websocketws { server localhost:3016; } upstream imservice { server localhost:3017; } server { listen 3006 backlog=1024; index index.html; server_name localhost; root /data/src/remote/h5; gzip on; gzip_disable "msie6"; # access_log /var/log/nginx/ws.access.log main; # error_log /var/log/nginx/ws.error.log; location / { proxy_pass http://websocketws; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_connect_timeout 5; proxy_read_timeout 60; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404; } } server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'sn, Content-Type'; add_header 'Access-Control-Expose-Headers' 'sn, Origin, X-Requested-With, Content-Type, Accept, Authorization'; add_header 'Access-Control-Allow-Headers' 'X-Custom-Header, Origin, X-Requested-With, Content-Type, Accept, Authorization'; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Referer $http_referer; proxy_pass http://appservice; proxy_http_version 1.1; proxy_set_header Connection ""; client_max_body_size 1000m; proxy_connect_timeout 5; proxy_read_timeout 60; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404; } location ~ ^/(acc|oauth)/ { add_header 'Access-Control-Allow-Origin' '$http_origin'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'sn, Content-Type'; add_header 'Access-Control-Expose-Headers' 'sn, Origin, X-Requested-With, Content-Type, Accept, Authorization'; add_header 'Access-Control-Allow-Headers' 'X-Custom-Header, Origin, X-Requested-With, Content-Type, Accept, Authorization'; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Referer $http_referer; proxy_pass http://oauth2; proxy_http_version 1.1; proxy_set_header Connection ""; client_max_body_size 1000m; proxy_connect_timeout 10; proxy_read_timeout 10; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404; } location ~ ^/(imroom|imtest|iminnerapi|test)/ { #add_header 'Access-Control-Allow-Origin' '*'; #add_header 'Access-Control-Allow-Credentials' 'true'; #add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; #add_header 'Access-Control-Allow-Headers' 'sn, Content-Type'; #add_header 'Access-Control-Expose-Headers' 'sn, Origin, X-Requested-With, Content-Type, Accept, Authorization'; #add_header 'Access-Control-Allow-Headers' 'X-Custom-Header, Origin, X-Requested-With, Content-Type, Accept, Authorization'; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Referer $http_referer; proxy_pass http://imservice; proxy_http_version 1.1; proxy_set_header Connection ""; client_max_body_size 1000m; proxy_connect_timeout 5; proxy_read_timeout 60; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404; } } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 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; # } #} }