前端vue-element-admin,后端springboot
nginx常用配置
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#隐藏版本号
server_tokens off;
gzip on;
gzip_min_length 1k;
gzip_comp_level 4;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_types image/jpeg image/png;
#不希望自己网页页面被其他站的FRAME嵌套
add_header X-Frame-Options DENY;
#http配置(无ssl证书配置)
server {
listen 80;
server_name www.xxx.com;
#rewrite ^(.*)$ https://$host$1; #将所有HTTP请求通过rewrite指令重定向到HTTPS。
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/local/www/front/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
#location /api {
# client_max_body_size 200m;
# proxy_pass http://localhost:8097/;
# proxy_set_header Host $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;
#}
#location /serverfile {
# client_max_body_size 200m;
# proxy_pass http://172.16.150.150/;
#}
#location =/ {
# rewrite / /404.html;
#}
#error_page 404 /404.html;
location = /404.html {
root html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
#内网访问配置
server {
listen 8080;
server_name xxx-in;
location / {
root /usr/local/www/front/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /serverfile {
client_max_body_size 200m;
proxy_pass http://172.16.150.150/;
}
}
#https访问配置
server {
listen 443 ssl;
server_name www.xxx.com;
index index.html index.htm;
ssl_certificate /usr/local/nginx/conf/cert/xxx.pem;
ssl_certificate_key /usr/local/nginx/conf/cert/xxx.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
#表示使用的加密套件的类型。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #表示使用的TLS协议的类型。
ssl_prefer_server_ciphers on;
#location / {
# root /usr/local/www/front/dist; #站点目录。
# index index.html index.htm;
# try_files $uri $uri/ /index.html;
#}
location /api/ {
client_max_body_size 200m;
proxy_pass http://localhost:8097/;
#proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto $scheme;
}
location /serverfile {
client_max_body_size 200m;
proxy_pass http://xxx.xxx.xxx.xxx/;
}
#该域名无首页,默认跳转到别的网站
location =/ {
rewrite ^/(.*) https://www.yyy.com/ permanent;
}
#error_page 404 /404.html;
location = /404.html {
root html;
}
}
}
启动脚本 startup.sh
该启动方式需将配置文件放在/usr/local/www/back文件夹下,>/dev/null不会产生nohup.out日志
cd /usr/local/www/back
chmod 777 project.jar
nohup java -Xms128m -Xmx1024m -Xmn896m -XX:+HeapDumpOnOutOfMemoryError -XX:ErrorFile=/usr/local/www/back/hs_err_pid%p.log -jar project.jar --spring.config.location=/usr/local/www/back/application.properties >/dev/null 2>&1 &
停止脚本 stop.sh
注意不要用kill -9强制停止,用kill -15会先执行停止代码,更优雅
cd /usr/local/www/back
pid=`ps -ef | grep project.jar | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]
then
kill -15 $pid
fi
|