nginx.conf 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. user nobody;
  2. worker_processes 2;
  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. client_max_body_size 30M;
  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. #keepalive_timeout 0;
  21. keepalive_timeout 65;
  22. gzip on;
  23. server {
  24. listen 98;
  25. location / {
  26. proxy_set_header Host $host;
  27. proxy_set_header X-Real-IP $remote_addr;
  28. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  29. proxy_pass http://127.0.0.1:9800;
  30. }
  31. location /mqtt {
  32. proxy_set_header Host $host;
  33. proxy_set_header X-Real-IP $remote_addr;
  34. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  35. proxy_pass http://127.0.0.1:1884;
  36. proxy_http_version 1.1;
  37. proxy_set_header Upgrade $http_upgrade;
  38. proxy_set_header Connection "upgrade";
  39. }
  40. }
  41. #静态文件根路径
  42. server {
  43. listen 81;
  44. location / {
  45. root /home/web/;
  46. try_files $uri $uri/ /index.html;
  47. index index.html;
  48. }
  49. }
  50. server {
  51. listen 80;
  52. server_name test.com localnet.com www.test.com 192.168.1.88;
  53. #charset koi8-r;
  54. access_log logs/host.access.log main;
  55. error_page 404 /404.html;
  56. error_page 500 502 503 504 /50x.html;
  57. location = /50x.html {
  58. root html;
  59. }
  60. location /statics/ {
  61. proxy_redirect off;
  62. proxy_set_header Host $host;
  63. proxy_set_header X-Real-IP $remote_addr;
  64. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  65. client_max_body_size 1000m;
  66. proxy_read_timeout 3600s;#超时设置
  67. proxy_pass http://127.0.0.1/labSystem/statics/;
  68. }
  69. location ^~/labSystem/admin/statics/ {
  70. proxy_redirect off;
  71. proxy_set_header Host $host;
  72. proxy_set_header X-Real-IP $remote_addr;
  73. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  74. client_max_body_size 1000m;
  75. proxy_read_timeout 3600s;#超时设置
  76. proxy_pass http://127.0.0.1/labSystem/statics/;
  77. }
  78. location /mettingroom/ {
  79. proxy_redirect off;
  80. proxy_set_header Host $host;
  81. proxy_set_header X-Real-IP $remote_addr;
  82. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  83. client_max_body_size 1000m;
  84. proxy_read_timeout 3600s;#超时设置
  85. proxy_pass http://127.0.0.1:8080/mettingroom/;
  86. }
  87. location ^~/mettingroom/admin/ {
  88. proxy_redirect off;
  89. proxy_set_header Host $host;
  90. proxy_set_header X-Real-IP $remote_addr;
  91. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  92. proxy_read_timeout 3600s;#超时设置
  93. proxy_pass http://127.0.0.1:81/mettingroom/;
  94. }
  95. #jenkins相关配置
  96. location /jenkins/ {
  97. proxy_redirect off;
  98. proxy_set_header Host $host;
  99. proxy_set_header X-Real-IP $remote_addr;
  100. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  101. client_max_body_size 1000m;
  102. proxy_read_timeout 3600s;#超时设置
  103. proxy_pass http://127.0.0.1:8082/jenkins/;
  104. }
  105. #git相关配置
  106. location /gogs/ {
  107. proxy_redirect off;
  108. proxy_set_header Host $host;
  109. proxy_set_header X-Real-IP $remote_addr;
  110. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  111. client_max_body_size 1000m;
  112. proxy_read_timeout 3600s;#超时设置
  113. proxy_pass http://127.0.0.1:3000/;
  114. }
  115. #wq相关配置
  116. location /wq/ {
  117. proxy_redirect off;
  118. proxy_set_header Host $host;
  119. proxy_set_header X-Real-IP $remote_addr;
  120. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  121. client_max_body_size 1000m;
  122. proxy_read_timeout 3600s;#超时设置
  123. proxy_pass http://127.0.0.1:8083/wq/;
  124. }
  125. location ^~/wq/admin/ {
  126. proxy_redirect off;
  127. proxy_set_header Host $host;
  128. proxy_set_header X-Real-IP $remote_addr;
  129. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  130. client_max_body_size 1000m;
  131. proxy_read_timeout 3600s;#超时设置
  132. proxy_pass http://127.0.0.1:81/wq/;
  133. }
  134. #wq相关配置
  135. location /xzgd/ {
  136. proxy_redirect off;
  137. proxy_set_header Host $host;
  138. proxy_set_header X-Real-IP $remote_addr;
  139. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  140. client_max_body_size 1000m;
  141. proxy_read_timeout 3600s;#超时设置
  142. proxy_pass http://127.0.0.1:8091/xzgd/;
  143. }
  144. location ^~/xzgd/admin/ {
  145. proxy_redirect off;
  146. proxy_set_header Host $host;
  147. proxy_set_header X-Real-IP $remote_addr;
  148. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  149. client_max_body_size 1000m;
  150. proxy_read_timeout 3600s;#超时设置
  151. proxy_pass http://127.0.0.1:81/xzgd/;
  152. }
  153. location /labSystem/ {
  154. proxy_redirect off;
  155. proxy_set_header Host $host;
  156. proxy_set_header X-Real-IP $remote_addr;
  157. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  158. client_max_body_size 1000m;
  159. proxy_read_timeout 3600s;#超时设置
  160. proxy_pass http://127.0.0.1:9800/;
  161. }
  162. location ^~/labSystem/admin/ {
  163. proxy_redirect off;
  164. proxy_set_header Host $host;
  165. proxy_set_header X-Real-IP $remote_addr;
  166. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  167. client_max_body_size 1000m;
  168. proxy_read_timeout 3600s;#超时设置
  169. proxy_pass http://127.0.0.1:81/labSystem/;
  170. }
  171. location ^~/labSystem/bigData/ {
  172. proxy_redirect off;
  173. proxy_set_header Host $host;
  174. proxy_set_header X-Real-IP $remote_addr;
  175. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  176. client_max_body_size 1000m;
  177. proxy_read_timeout 3600s;#超时设置
  178. proxy_pass http://127.0.0.1:81/bigData/;
  179. }
  180. location ^~/labSystem/labBigData/ {
  181. proxy_redirect off;
  182. proxy_set_header Host $host;
  183. proxy_set_header X-Real-IP $remote_addr;
  184. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  185. client_max_body_size 1000m;
  186. proxy_read_timeout 3600s;#超时设置
  187. proxy_pass http://127.0.0.1:81/labBigData/;
  188. }
  189. }
  190. server {
  191. listen 443 ssl;
  192. server_name lab.sxitdlc.com;
  193. #ssl on;
  194. ssl_certificate /usr/local/nginx/cert/server.crt;
  195. ssl_certificate_key /usr/local/nginx/cert/server.key;
  196. ssl_session_timeout 5m;
  197. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  198. ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
  199. ssl_prefer_server_ciphers on;
  200. #add_header Access-Control-Allow-Origin *;
  201. #add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
  202. #add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
  203. #if ($request_method = 'OPTIONS') {
  204. # return 204;
  205. #}
  206. location / {
  207. root /home/;
  208. #index index.html index.htm;
  209. }
  210. location /statics/ {
  211. proxy_redirect off;
  212. proxy_set_header Host $host;
  213. proxy_set_header X-Real-IP $remote_addr;
  214. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  215. client_max_body_size 1000m;
  216. proxy_read_timeout 3600s;#超时设置
  217. proxy_pass http://127.0.0.1/labSystem/statics/;
  218. }
  219. location ^~/labSystem/admin/statics/ {
  220. proxy_redirect off;
  221. proxy_set_header Host $host;
  222. proxy_set_header X-Real-IP $remote_addr;
  223. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  224. client_max_body_size 1000m;
  225. proxy_read_timeout 3600s;#超时设置
  226. proxy_pass http://127.0.0.1/labSystem/statics/;
  227. }
  228. location /labSystem/ {
  229. proxy_redirect off;
  230. proxy_set_header Host $host;
  231. proxy_set_header X-Real-IP $remote_addr;
  232. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  233. client_max_body_size 1000m;
  234. proxy_read_timeout 3600s;#超时设置
  235. proxy_pass http://127.0.0.1:9800/;
  236. }
  237. location ^~/labSystem/admin/ {
  238. proxy_redirect off;
  239. proxy_set_header Host $host;
  240. proxy_set_header X-Real-IP $remote_addr;
  241. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  242. client_max_body_size 1000m;
  243. proxy_read_timeout 3600s;#超时设置
  244. proxy_pass http://127.0.0.1:81/labSystem/;
  245. }
  246. location /mqtt {
  247. proxy_pass http://127.0.0.1:1884;
  248. proxy_set_header Host $host;
  249. proxy_set_header X-Real-IP $remote_addr;
  250. proxy_set_header X-Forwarded-For $remote_addr;
  251. proxy_http_version 1.1;
  252. proxy_set_header Upgrade $http_upgrade;
  253. proxy_set_header Connection "upgrade";
  254. proxy_set_header Sec-WebSocket-Protocol mqtt;
  255. }
  256. }
  257. }