我安装了宝塔面板之后,安装nginx,在左侧菜单【网站】菜单下的【Java项目】选项中安装了tomcat,环境变量、Java路径都OK,
添加好了Java项目之后项目运行OK,可以通过8080端口访问,
绑定域名后问题就来了,仍需要在域名后加端口号8080才能访问到项目。访问默认的80端口是访问不到项目的,但是我看项目的配置文件中,反向代理配置是包含了域名的,域名绑定的端口也是80端口。端口占用情况: root@VM-16-12-debian:~# sudo lsof -i :80 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME nginx 1031 root 9u IPv4 16904 0t0 TCP *:http (LISTEN) nginx 17027 www 9u IPv4 16904 0t0 TCP *:http (LISTEN) nginx 17028 www 9u IPv4 16904 0t0 TCP *:http (LISTEN) Java项目的配置文件内容 server { listen 80; server_name luining.cn www.luining.cn; index index.html index.htm default.htm default.html; root /www/wwwroot/buy.union; #SSL-START SSL相关配置 #error_page 404/404.html; #SSL-END #ERROR-PAGE-START 错误页相关配置 #error_page 404 /404.html; #error_page 502 /502.html; #ERROR-PAGE-END #REWRITE-START 伪静态相关配置 include /www/server/panel/vhost/rewrite/java_union-1.conf; #REWRITE-END #禁止访问的文件或目录 location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md|package.json|package-lock.json|\.env) { return 404; } #一键申请SSL证书验证目录相关设置 location /.well-known/ { root /www/wwwroot/java_node_ssl; } #禁止在证书验证目录放入敏感文件 if ( $uri ~ "^/\.well-known/.*\.(php|jsp|py|js|css|lua|ts|go|zip|tar\.gz|rar|7z|sql|bak)$" ) { return 403; } # HTTP反向代理相关配置开始 >>> location ~ /purge(/.*) { proxy_cache_purge cache_one $Host$request_uri$is_args$args; } location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $Host:server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header REMOTE-HOST $remote_addr; add_header X-Cache $upstream_cache_status; proxy_set_header X-Host $host:server_port; proxy_set_header X-Scheme $scheme; proxy_connect_timeout 30s; proxy_read_timeout 86400s; proxy_send_timeout 30s; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } # HTTP反向代理相关配置结束 <<< access_log /www/wwwlogs/union-1.log; error_log /www/wwwlogs/union-1.error.log; } 以下是宝塔面板软件列表的nginx配置内容 user www www;worker_processes auto;
error_log /www/wwwlogs/nginx_error.log crit;
pid /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;
stream {
log_format tcp_format '$time_local|$remote_addr|$protocol|$status|$bytes_sent|$bytes_received|$session_time|$upstream_addr|$upstream_bytes_sent|$upstream_bytes_received|$upstream_connect_time';
access_log /www/wwwlogs/tcp-access.log tcp_format;
error_log /www/wwwlogs/tcp-error.log;
include /www/server/panel/vhost/nginx/tcp/*.conf;
}
events
{
use epoll;
worker_connections 51200;
multi_accept on;
}
http
{
include mime.types;
#include luawaf.conf;
include proxy.conf;
default_type application/octet-stream;
server_names_hash_bucket_size 512;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
limit_conn_zone $binary_remote_addr zone=perip:10m;
limit_conn_zone $server_name zone=perserver:10m;
server_tokens off;
access_log off;
server
{
listen 888;
server_name phpmyadmin;
index index.html index.htm index.php;
root /www/server/phpmyadmin;
allow 127.0.0.1;
allow ::1;
deny all;
#error_page 404 /404.html;
include enable-php.conf;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /\.
{
deny all;
}
access_log /www/wwwlogs/access.log;
}
include /www/server/panel/vhost/nginx/*.conf;
}
|
|