生产环境Nginx配置-常用命令

时间:2024-07-20 13:16:42

1、cd /www/wwwroot/runtime/source-vue(切换到jar包目录)

2、关闭应用

ps -aux | grep java (查看在运行的PID)

kill -9 PID (停止运行)

3、启动应用

nohup java -jar source-admin.jar >/usr/sourcebyte/temp.txt & (启动应用并输出日志到临时文件)

Nginx配置

server
{
    listen 80;
	listen 443 ssl http2;
    server_name sourcebyte.vip www.sourcebyte.vip;
    include       mime.types;
    default_type  application/octet-stream;
    proxy_intercept_errors on;
    sendfile        on;
    keepalive_timeout  65;
    # gzip config
    gzip on;
    gzip_min_length 1k;
    gzip_comp_level 9;
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary on;
    gzip_disable "MSIE [1-6]\.";
    client_max_body_size 1024m;
    proxy_set_header        X-Real-IP       $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

    #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
    #error_page 404/404.html;
    #HTTP_TO_HTTPS_START
    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }
    #HTTP_TO_HTTPS_END
    ssl_certificate    /www/server/panel/vhost/cert/sourcebyte.vip/fullchain.pem;
    ssl_certificate_key    /www/server/panel/vhost/cert/sourcebyte.vip/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";
    error_page 497  https://$host$request_uri;
		#SSL-END

    #ERROR-PAGE-START  错误页配置,可以注释、删除或修改
    #error_page 404 /404.html;
    #error_page 502 /502.html;
    #ERROR-PAGE-END

    #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
    include /www/server/panel/vhost/rewrite/sourcebyte.vip.conf;
    #REWRITE-END
    
    access_log  /www/wwwlogs/sourcebyte.vip.log;
    error_log  /www/wwwlogs/sourcebyte.vip.error.log;
    
    location / {				
			if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)) {
				root  /www/wwwroot/sourcebyte.vip/html/site/mobile/h5;
			}
			root   /www/wwwroot/sourcebyte.vip/html/site/dist/;
			index  index.html index.html;
			try_files $uri $uri/ /index.html; 
    }	
    
    location /h5 {
		alias  /www/wwwroot/sourcebyte.vip/html/site/mobile/h5/;
		index  index.html index.html;
		try_files $uri $uri/ /index.html; 
	}
		
	location /article/ {
		proxy_pass https://sourcebyte.vip/h5/pages/article/article; # 转发到手机文章地址
	}
	#接口映射	
	location /api/ {
		 proxy_pass http://localhost:9001/api/;  # 转发地址
	}
	#app common 映射	
	location /common/ {
		  proxy_pass http://localhost:9001/common/;  # 转发地址
	}
	#富文本地址资源映射
	location /web-api/ {	
  		proxy_set_header Host $http_host;
  		proxy_set_header X-Real-IP $remote_addr;
  		proxy_set_header REMOTE-HOST $remote_addr;
  		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  		#websocket
  		proxy_set_header Upgrade $http_upgrade;             
        proxy_set_header Connection "upgrade";
  		proxy_pass http://localhost:9001/;
  	}
  	
  	location /profile {
    	add_header Access-Control-Allow-Origin *;
    	add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
    	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';
    	if ($request_method = 'OPTIONS') {
    		return 204;
    	}	
    	alias  /www/wwwroot/static/uploadPath/;
    	index  index.html index.html;
    }
}

如若转载,请注明出处:开源字节   https://sourcebyte.vip/article/361.html