服务器部署Nginx和Tomcat设置

版权声明:个人发声,博客技术文章都是本人项目工程经验积累,转载请注明!(物联网云平台全站设计师-承接软硬件设计、微信、web前端、Java后台、云平台搭建项目,请联系微信:28775855,邮件:[email protected]) https://blog.csdn.net/phlr5/article/details/83374278

服务器部署Nginx和Tomcat设置

Nginx部署

nginx.conf文件配置:

#user nginx;
user root;

worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 1024;
}

http {
log_format main '$remote_addr - r e m o t e u s e r [ remote_user [ time_local] “KaTeX parse error: Double superscript at position 34: … '̲status b o d y b y t e s s e n t " body_bytes_sent " http_referer” ’
‘“ h t t p u s e r a g e n t " " http_user_agent" " http_x_forwarded_for”’;

access_log  /var/log/nginx/access.log  main;

sendfile            on;
tcp_nopush          on;
tcp_nodelay         on;
keepalive_timeout   65;
types_hash_max_size 2048;

include             /etc/nginx/mime.types;
default_type        application/octet-stream;


server_names_hash_bucket_size  128;
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;


# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;

server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  xxx.com www.xxx.com ;
root		/usr/local/tomcat/apache-tomcat-9.0.12/webapps;
    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

	location ^~ /dist/ {
         proxy_pass   http://xxx.com:1000/dist/;
         try_files $uri $uri/ /dist/index.html;
 }

location ^~ /garcol/ {
    proxy_pass   http://xxx.com:1000/garcol/;
    }

location ^~ /ioe/ {
    proxy_pass http://xxx.com:1000/ioe/;
    }

    location /airobot/ {
         proxy_read_timeout 600s;
         proxy_set_header  X-Real-IP  $remote_addr;
         proxy_set_header Host $host:$server_port;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

     proxy_pass http://xxx.com:1000/airobot/;
    }
location ^~ / {
    proxy_pass http://xxx.com:1000/xxx/;
    }
location ~ \.jsp$ {
	proxy_pass http://127.0.0.1:7000;
	proxy_set_header Host $host;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-Proto $scheme;
}



    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }
}


server {
  listen       1809;
  server_name xxx.com ;

  #charset koi8-r;
  #access_log  /var/log/nginx/host.access.log  main;

  location / {
    #root   /usr/share/nginx/html/dist2;
    root   /root/dist/;
    #index  index.html index.htm;
    try_files $uri $uri/ /index.html;

    #access_log  /var/log/nginx/seo_ff.access.log  main;
    #error_log  /var/log/nginx/seo_ff.error.log notice;
  }
}

}

Tomcat部署

在server.xml文件中
加入
<Context docBase="/usr/local/tomcat/webapps/project" path="/project" debug=“0” reloadable=“true”/>

基本上差不多了

猜你喜欢

转载自blog.csdn.net/phlr5/article/details/83374278
今日推荐