当前位置:   article > 正文

nginx 80端口映射多个应用_nginx kafka 绑定80端口

nginx kafka 绑定80端口

nginx 80端口映射多个应用

更多干货

一、配置文件

  • worker_connections 默认最大的并发数为1024,如果你的网站访问量过大,已经远远超过1024这个并发数,那你就要修改worker_connecions这个值 ,这个值越大,并发数也有就大。当然,你一定要按照你自己的实际情况而定,也不能设置太大,不能让你的CPU跑满100%。
  • worker_processes 一般来说,设置成CPU核的数量即可

nginx.conf

  1. worker_processes 1;
  2. events {
  3. worker_connections 1024;
  4. }
  5. http {
  6. fastcgi_buffer_size 128k;
  7. fastcgi_buffers 4 256k;
  8. fastcgi_busy_buffers_size 256k;
  9. fastcgi_temp_file_write_size 256k;
  10. gzip on;
  11. gzip_min_length 1k;
  12. gzip_buffers 4 16k;
  13. gzip_http_version 1.0;
  14. gzip_comp_level 2;
  15. gzip_types text/plain application/x-javascript text/css application/xml;
  16. gzip_vary on;
  17. server {
  18. listen 80;
  19. server_name localhost ;
  20. index index.jsp index.html;
  21. location / {
  22. proxy_pass http://127.0.0.1:8080;
  23. proxy_set_header X-Real-IP $remote_addr;
  24. proxy_redirect off;
  25. proxy_set_header Host $host;
  26. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  27. client_max_body_size 10m;
  28. client_body_buffer_size 128k;
  29. proxy_buffers 32 4k;
  30. proxy_connect_timeout 3;
  31. proxy_send_timeout 30;
  32. proxy_read_timeout 30;
  33. }
  34. location /server2 {
  35. proxy_pass http://127.0.0.1:9080;
  36. proxy_set_header X-Real-IP $remote_addr;
  37. proxy_redirect off;
  38. proxy_set_header Host $host;
  39. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  40. client_max_body_size 10m;
  41. client_body_buffer_size 128k;
  42. proxy_buffers 32 4k;
  43. proxy_connect_timeout 3;
  44. proxy_send_timeout 30;
  45. proxy_read_timeout 30;
  46. }
  47. }
  48. }

二、映射server1

80 端口映射到 8080 tomcat 的ROOT 下 image

三、映射server2

80/server2 端口映射到 9080 tomcat 的webApp/server2下

 

注意:server2 不能反正tomcat/ROOT下。一定与nginx中的保持一致 

 image

 

  1. #user nobody;
  2. worker_processes 1;
  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. events {
  8. worker_connections 1024;
  9. }
  10. http {
  11. include mime.types;
  12. default_type application/octet-stream;
  13. sendfile on;
  14. #keepalive_timeout 0;
  15. keepalive_timeout 65;
  16. #gzip on;
  17. server {
  18. listen 8088;
  19. server_name localhost;
  20. location /api/ {
  21. proxy_pass http://127.0.0.1:8090/;
  22. }
  23. location /proxy/ {
  24. proxy_pass http://127.0.0.1:8090/;
  25. }
  26. location / {
  27. root C:/server/web;
  28. index index.html;
  29. try_files $uri $uri/ /index.html;
  30. }
  31. error_page 500 502 503 504 /50x.html;
  32. location = /50x.html {
  33. root html;
  34. }
  35. }
  36. }

 

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号