1. user root;
    2. worker_processes 4;
    3. #error_log logs/error.log;
    4. #error_log logs/error.log notice;
    5. #error_log logs/error.log info;
    6. #pid logs/nginx.pid;
    7. worker_rlimit_nofile 65535;
    8. events {
    9. worker_connections 65535;
    10. }
    11. http {
    12. include mime.types;
    13. default_type application/octet-stream;
    14. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    15. # '$status $body_bytes_sent "$http_referer" '
    16. # '"$http_user_agent" "$http_x_forwarded_for"';
    17. #access_log logs/access.log main;
    18. sendfile on;
    19. #tcp_nopush on;
    20. add_header X-Frame-Options SAMEORIGIN;
    21. #keepalive_timeout 0;
    22. keepalive_timeout 2400;
    23. #gzip on;
    24. proxy_connect_timeout 6000; #单位秒
    25. proxy_send_timeout 6000; #单位秒
    26. proxy_read_timeout 6000; #单位秒
    27. proxy_buffer_size 1024k;
    28. proxy_buffers 4 1024k;
    29. proxy_busy_buffers_size 1024k;
    30. proxy_temp_file_write_size 1024k;
    31. include /etc/nginx/conf.d/framework_upstream.conf;
    32. server {
    33. listen 8099;
    34. server_name localhost;
    35. proxy_send_timeout 600;
    36. proxy_read_timeout 600;
    37. proxy_connect_timeout 600;
    38. client_max_body_size 5120m;
    39. }
    40. server {
    41. #listen 9099;
    42. listen 443 ssl default;
    43. server_name localhost;
    44. location / {
    45. if ( $request_uri = "/" ) {
    46. rewrite "/" https://10.42.34.100:$server_port/dgdpsportal/#/index break;
    47. }
    48. }
    49. proxy_send_timeout 600;
    50. proxy_read_timeout 600;
    51. proxy_connect_timeout 600;
    52. client_max_body_size 5120m;
    53. #允许跨域请求的域,* 代表所有
    54. add_header 'Access-Control-Allow-Origin' *;
    55. #允许带上cookie请求
    56. add_header 'Access-Control-Allow-Credentials' 'true';
    57. #允许请求的方法,比如 GET/POST/PUT/DELETE
    58. add_header 'Access-Control-Allow-Methods' *;
    59. #允许请求的header
    60. add_header 'Access-Control-Allow-Headers' *;
    61. # 引用ssl证书
    62. ssl_certificate /etc/nginx/ssl/server.crt;
    63. ssl_certificate_key /etc/nginx/ssl/server.key;
    64. # 协议优化(可选,优化https协议,增强安全性)
    65. ssl_protocols TLSv1.2;
    66. # ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    67. ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    68. ssl_prefer_server_ciphers on;
    69. ssl_session_cache shared:SSL:10m;
    70. ssl_session_timeout 10m;
    71. include /etc/nginx/conf.d/framework_location.conf;
    72. }
    73. }

    proxyconnect_timeout :后端服务器连接的超时时间发起握手等候响应超时时间(默认60秒) proxyread_timeout:连接成功后等候后端服务器响应时间其实已经进入后端的排队之中等候处理(也可以说是后端服务器处理请求的时间) proxy_send_timeout :后端服务器数据回传时间就是在规定时间之内后端服务器必须传完所有的数据

    说明,重定向实现 在nginx中配置ip直接访问的默认站点

    1. location / {
    2. if ( $request_uri = "/" ) {
    3. rewrite "/" https://10.42.34.100:$server_port/dgdpsportal/#/index break;
    4. }
    5. }

    framework_upstream.conf

    1. upstream idatafusion {
    2. server 127.0.0.1:10000 weight=1;
    3. }

    framework_location.conf

    1. location /idatafusion{
    2. proxy_set_header Host $host:$server_port;
    3. proxy_set_header X-Real-IP $remote_addr;
    4. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    5. proxy_cookie_path /idatafusion /idatafusion;
    6. proxy_set_header Cookies $http_cookies;
    7. proxy_set_header X-Forwarded-Proto $scheme;
    8. proxy_buffer_size 128k;
    9. proxy_buffers 8 128k;
    10. proxy_busy_buffers_size 128k;
    11. proxy_pass http://idatafusion/idatafusion;
    12. }