nginx原配置文件如下:

  1. #user nobody;
  2. worker_processes ;
  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. events {
  11. worker_connections ;
  12. }
  13.  
  14. http {
  15. include mime.types;
  16. default_type application/octet-stream;
  17.  
  18. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  19. # '$status $body_bytes_sent "$http_referer" '
  20. # '"$http_user_agent" "$http_x_forwarded_for"';
  21.  
  22. #access_log logs/access.log main;
  23.  
  24. sendfile on;
  25. #tcp_nopush on;
  26.  
  27. #keepalive_timeout ;
  28. keepalive_timeout ;
  29.  
  30. #gzip on;
  31.  
  32. server {
  33. listen ;
  34. server_name localhost;
  35.  
  36. #charset koi8-r;
  37.  
  38. #access_log logs/host.access.log main;
  39.  
  40. location / {
  41. root html;
  42. index index.html index.htm;
  43. }
  44.  
  45. #error_page /.html;
  46.  
  47. # redirect server error pages to the static page /50x.html
  48. #
  49. error_page /50x.html;
  50. location = /50x.html {
  51. root html;
  52. }
  53.  
  54. # proxy the PHP scripts to Apache listening on 127.0.0.1:
  55. #
  56. #location ~ \.php$ {
  57. # proxy_pass http://127.0.0.1;
  58. #}
  59.  
  60. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
  61. #
  62. #location ~ \.php$ {
  63. # root html;
  64. # fastcgi_pass 127.0.0.1:;
  65. # fastcgi_index index.php;
  66. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  67. # include fastcgi_params;
  68. #}
  69.  
  70. # deny access to .htaccess files, if Apache's document root
  71. # concurs with nginx's one
  72. #
  73. #location ~ /\.ht {
  74. # deny all;
  75. #}
  76. }
  77.  
  78. # another virtual host using mix of IP-, name-, and port-based configuration
  79. #
  80. #server {
  81. # listen ;
  82. # listen somename:;
  83. # server_name somename alias another.alias;
  84.  
  85. # location / {
  86. # root html;
  87. # index index.html index.htm;
  88. # }
  89. #}
  90.  
  91. # HTTPS server
  92. #
  93. #server {
  94. # listen ;
  95. # server_name localhost;
  96.  
  97. # ssl on;
  98. # ssl_certificate cert.pem;
  99. # ssl_certificate_key cert.key;
  100.  
  101. # ssl_session_timeout 5m;
  102.  
  103. # ssl_protocols SSLv2 SSLv3 TLSv1;
  104. # ssl_ciphers HIGH:!aNULL:!MD5;
  105. # ssl_prefer_server_ciphers on;
  106.  
  107. # location / {
  108. # root html;
  109. # index index.html index.htm;
  110. # }
  111. #}
  112.  
  113. }

配置代理

  1. #user nobody;
  2. worker_processes ;
  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. events {
  11. worker_connections ;
  12. }
  13.  
  14. http {
  15. include mime.types;
  16. default_type application/octet-stream;
  17.  
  18. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  19. # '$status $body_bytes_sent "$http_referer" '
  20. # '"$http_user_agent" "$http_x_forwarded_for"';
  21.  
  22. #access_log logs/access.log main;
  23.  
  24. sendfile on;
  25. #tcp_nopush on;
  26.  
  27. #keepalive_timeout ;
  28. keepalive_timeout ;
  29.  
  30. #gzip on;
  31.  
  32. upstream jsnk_server {
  33. ip_hash;
  34. server 192.168.1.105:8085 max_fails=3 fail_timeout=30s;
  35. server 192.168.2.210:8085 max_fails=3 fail_timeout=30s;
  36. #server 121.40.253.125:8085 max_fails=3 fail_timeout=30s;
  37. }
  38. upstream skerm_server {
  39. ip_hash;
  40. server 192.168.1.105:9558 max_fails=3 fail_timeout=30s;
  41. server 192.168.2.210:9558 max_fails=3 fail_timeout=30s;
  42. #server 121.40.253.125:9558 max_fails=3 fail_timeout=30s;
  43. }
  44.  
  45. server {
  46. listen ;
  47. server_name 192.168.2.207;
  48. large_client_header_buffers 4 16k;
  49. client_max_body_size 300m;
  50. client_body_buffer_size 128k;
  51. proxy_connect_timeout 600;
  52. proxy_read_timeout 600;
  53. proxy_send_timeout 600;
  54. proxy_buffer_size 64k;
  55. proxy_buffers 4 32k;
  56. proxy_busy_buffers_size 64k;
  57. proxy_temp_file_write_size 64k;
  58.  
  59. location /jsnk {
  60. uwsgi_send_timeout 600;
  61. uwsgi_connect_timeout 600;
  62. uwsgi_read_timeout 600;
  63. proxy_pass http://jsnk_server/jsnk;
  64. proxy_set_header Host $host:$server_port;
  65. proxy_set_header X-Real-IP $remote_addr;
  66. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  67. proxy_set_header Upgrade $http_upgrade;
  68. proxy_set_header Connection 'upgrade';
  69. index index.html index.htm;
  70. }
  71. location /skerm {
  72. proxy_pass http://skerm_server/skerm;
  73. proxy_set_header Host $host:$server_port;
  74. proxy_set_header X-Real-IP $remote_addr;
  75. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  76. proxy_set_header Upgrade $http_upgrade;
  77. proxy_set_header Connection 'upgrade';
  78. index index.html index.htm;
  79. }
  80.  
  81. #error_page /.html;
  82.  
  83. # redirect server error pages to the static page /50x.html
  84. #
  85. error_page /50x.html;
  86. location = /50x.html {
  87. root html;
  88. }
  89.  
  90. # proxy the PHP scripts to Apache listening on 127.0.0.1:
  91. #
  92. #location ~ \.php$ {
  93. # proxy_pass http://127.0.0.1;
  94. #}
  95.  
  96. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
  97. #
  98. #location ~ \.php$ {
  99. # root html;
  100. # fastcgi_pass 127.0.0.1:;
  101. # fastcgi_index index.php;
  102. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  103. # include fastcgi_params;
  104. #}
  105.  
  106. # deny access to .htaccess files, if Apache's document root
  107. # concurs with nginx's one
  108. #
  109. #location ~ /\.ht {
  110. # deny all;
  111. #}
  112. }
  113.  
  114. # another virtual host using mix of IP-, name-, and port-based configuration
  115. #
  116. #server {
  117. # listen ;
  118. # listen somename:;
  119. # server_name somename alias another.alias;
  120.  
  121. # location / {
  122. # root html;
  123. # index index.html index.htm;
  124. # }
  125. #}
  126.  
  127. # HTTPS server
  128. #
  129. #server {
  130. # listen ;
  131. # server_name localhost;
  132.  
  133. # ssl on;
  134. # ssl_certificate cert.pem;
  135. # ssl_certificate_key cert.key;
  136.  
  137. # ssl_session_timeout 5m;
  138.  
  139. # ssl_protocols SSLv2 SSLv3 TLSv1;
  140. # ssl_ciphers HIGH:!aNULL:!MD5;
  141. # ssl_prefer_server_ciphers on;
  142.  
  143. # location / {
  144. # root html;
  145. # index index.html index.htm;
  146. # }
  147. #}
  148.  
  149. }

end

配置nginx代理服务器访问tomcat服务的更多相关文章

  1. docker Dockerfile学习---nginx负载均衡tomcat服务

    1.此过程在nginx的基础上,也就是上篇博客写的内容. 2.创建项目目录并上传包,解压 $ mkdir centos_tomcat $ cd centos_tomcat $ tar zxvf jdk ...

  2. centos7+nginx负载均衡Tomcat服务

    接着上一篇:www.cnblogs.com/lkun/p/8252815.html 我们在上一篇在一台centos7服务器上部署了两个nginx,接下来我们使用一个nginx实现tomcat的负载均衡 ...

  3. Windows下配置开机自启Tomcat服务

    给单位内部做了一个管理系统,部署项目要求服务器启动管理系统自启..直接给出操作流程. 一.配置环境变量 由于Tomcat启动依赖jdk,因此需要配置jdk与Tomcat两项环境变量,如系统已安装jdk ...

  4. 配置非安装版tomcat服务

    1.设置服务名称,进入tomcat目录/bin文件夹,编辑service.bat中的 set SERVICE_NAME = (修改成你需要的服务名,这个将是你启动服务的句柄): 2.修改 set PR ...

  5. 阿里云上,Ubuntu下配置Nginx,在tomcat中加了https协议就不可以了

    问题 阿里云上,Ubuntu服务器,本来部署的是tomcat,并且使用了https 协议.后来为了静态资源分离集成了 nginx,nginx代理跳转到 tomcat.刚开始直接访问http 网址发现, ...

  6. 配置Nginx代理服务器

    nginx另一个使用的比较多的情况是作为代理服务器,代理服务器接收请求,然后把请求传递到代理服务器,nginx最后会提取代理服务器的回复,并把这些回复发送给客户端.我们将配置一个基本的代理服务器,图片 ...

  7. 虚拟机配置nginx无法访问80端口

    在虚拟机中配置成功并正常启动nginx服务后,但浏览器无法访问服务,原因可能是linux中未开放80端口(nginx默认的端口为80). 1.执行该命令打开端口文件 vi /etc/sysconfig ...

  8. 安装配置nginx之后访问不了nginx的问题

    我刚开通的服务器,没有设置安全组规则. 进入云服务控制台 配置规则 其他不要动,授权对象加0.0.0.0/0 就可以访问nginx了

  9. LNMP配置——Nginx配置 —— Nginx的访问日志

    一.配置 先来看看Nginx的日志格式 #grep -A2 log_format /usr/local/nginx/conf/nginx.conf log_format combined_realip ...

随机推荐

  1. python 找到项目使用的所有组件和版本

    1.下载模块 pip3 install -i https://pypi.douban.com/simple pipreqs 2.生成文件 pipreqs ./ --encoding=utf-8

  2. Oracle GoldenGate for BigData-Kafka

    0. Env list:Oracle Linux:6.10Oracle DB 11.2.0.4OGG4Ora:19.1OGG4BD:19.1 1.Install package for OCI ins ...

  3. 十大排序算法(Java实现)

    一.冒泡排序(Bubble Sort) public class BubbleSort { public static void main(String[] args) { int[] arr = { ...

  4. vuex 基本语法

    VUEX 的核心概念 1 .State (常用):2.Getters :3.Mutations(常用):4.Actions :5.Modules: 1.State是唯一的数据源,单一的状态树 cons ...

  5. 一文带你了解 HTTP 黑科技

    这是 HTTP 系列的第三篇文章,此篇文章为 HTTP 的进阶文章. 在前面两篇文章中我们讲述了 HTTP 的入门,HTTP 所有常用标头的概述,这篇文章我们来聊一下 HTTP 的一些 黑科技. HT ...

  6. allegro使用经验总结(一)

    在用allegro开发flappy bird.游戏虽然小,但是用到了allegro的方方面面,可以说是"麻雀虽小五脏俱全". 1.physfs 这是一个跨平台的读写文件的库,可以直 ...

  7. 创建dynamics CRM client-side (九) - 用JS来获取look up 信息

    我们用以下的代码可以获取到look up 的信息. 大家可以查看微软文档来查看更多关于 lookup object的信息 https://docs.microsoft.com/en-us/powera ...

  8. testng使用详解

    一.testng 介绍 TestNG 是一个测试框架,其灵感来自 JUnit 和 NUnit,但同时引入了一些新的功能,使其功能更强大,使用更方便. TestNG 设计涵盖所有类型的测试:单元,功能, ...

  9. cnblogs 美化主题

    Silence主题 一个简洁的主题, 不带广告,我很喜欢 cnblogs 域名解析 这需要注意一点是:github.io项目名需要和用户名一致才能正确访问,否则会报404 Markdown格式化编辑 ...

  10. 一次完整的OCR实践记录

    一.任务介绍 这次的任务是对两百余张图片里面特定的编号进行识别,涉及保密的原因,这里就不能粘贴出具体的图片了,下面粘贴出一张类似需要识别的图片. 假如说我的数据源如上图所示,那么我需要做的工作就是将上 ...