我正在网上搜索很长时间。但是没用。请帮助或尝试给出一些想法来实现这一目标。 这是我的问题:访问域名www.ironxi.com,浏览器却访问了我:404,您能帮我解决这个问题吗? 运行环境:java 1.7.0.75; mysql-server5.1.73; tomcat 7.0.29; nginx 1.10.2; CentOS6服务器;
1。目标:部署我的第一个网站项目,每个人都可以访问它;
2.design:
2.1install&Configuration jdk(成功): 这是信息: Java版本“ 1.7.0_75” Java(TM)SE运行时环境(内部版本1.7.0_75-b13) Java HotSpot(TM)64位服务器VM(内部版本24.75-b04,混合模式)
2.2install&Configuration tomcat: 这是开始成功的信息: enter image description here 2.3安装&配置mysql,然后创建数据库和表: enter image description here
2.4install&Configuration nginx,这里是nginx.conf(为了我的网络安全,我使用888.888.888.888替换我的真实IP,使用我们的端口代替开放的真实端口,使用one.example.com替换我的真实域名)
user nginx;
worker_processes 1;
pid /var/run/nginx.pid;
# [ debug | info | notice | warn | error | crit ]
error_log /var/log/nginx.error_log info;
events {
worker_connections 1024;
# use [ kqueue | rtsig | epoll | /dev/poll | select | poll ] ;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';
log_format download '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$http_range" "$sent_http_content_range"';
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
output_buffers 1 32k;
postpone_output 1460;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
##send_lowat 12000;
keepalive_timeout 75 20;
# lingering_time 30;
# lingering_timeout 10;
# reset_timedout_connection on;
server {
listen port;
server_name college.one.example.com www.college.one.example.com;
access_log /var/log/nginx.access_log main;
# new location
location ~ \.jsp$ {
index index.html index.jsp;
proxy_pass http://localhost:port;
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;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
location / {
# new configuration;
root html;
index index.html index.htm index.jsp;
deny 888.8888.888.8888;
proxy_pass http://127.0.0.1/;
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;
client_max_body_size 10m;
client_body_buffer_size 128k;
##client_body_temp_path /var/nginx/client_body_temp;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
##proxy_send_lowat 12000;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
##proxy_temp_path /var/nginx/proxy_temp;
##charset koi8-r;
}
error_page 404 /404.html;
location /404.html {
root /usr/java/tomcat/apache-tomcat-7.0.29/webapps/ocPortal/WEB-INF/pages/error;
charset on;
## source_charset koi8-r;
}
location /old_stuff/ {
rewrite ^/old_stuff/(.*)$ /new_stuff/$1 permanent;
}
location /download/ {
valid_referers none blocked server_names *.example.com;
if ($invalid_referer) {
#rewrite ^/ http://www.college.one.example.com/;
return 403;
}
# rewrite_log on;
# rewrite /download/*/mp3/*.any_ext to /download/*/mp3/*.mp3
rewrite ^/(download/.*)/mp3/(.*)\..*$ /$1/mp3/$2.mp3 break;
root /usr/java/tomcat/apache-tomcat-7.0.29/webapps/ocPortal;
# autoindex on;
access_log /var/log/nginx-download.access_log download;
}
location ~* ^.+\.(gif|jpg|jpeg|gif|bmp|swf)$ {
root /usr/java/tomcat/apache-tomcat-7.0.29/webapps/ocPortal;
access_log off;
expires 30d;
}
}
# coder10
server {
listen port;
# listen 443 ssl;
server_name www.college.one.example.com college.one.example.com ;
index index.html index.htm index.jsp;
root /usr/java/tomcat/apache-tomcat-7.0.29/webapps/ocPortal;
location / {
proxy_pass http://127.0.0.1:port/ocPortal/;
proxy_cookie_path /ocPortal/ /;
proxy_redirect http://www.college.one.example.com/ocPortal/ http://college.one.example.com ;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_buffers 32 4k;
proxy_connect_timeout 3;
proxy_send_timeout 30;
proxy_read_timeout 30;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 1h;
}
}
include /etc/nginx/conf.d/*.conf;
}
2.4将war文件上传到/usr/java/tomcat/apache-tomcat-7.0.29/webapps,然后启动tomcat和nginx;
3。结果:我无法访问该网站: enter image description here enter image description here
4。您想帮助解决此错误吗?我真的不知道该如何解决,我花了三天的时间解决此错误。