作者: whooyun发表于: 2017-04-10 21:39
# For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes 1; error_log /var/log/nginx/error.log; #error_log /var/log/nginx/error.log notice; #error_log /var/log/nginx/error.log info; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; # Load config files from the /etc/nginx/conf.d directory # The default server is in conf.d/default.conf include /etc/nginx/conf.d/*.conf; server { listen 80; server_name www.daxiao123.com daxiao123.com; #charset koi8-r; #access_log logs/host.access.log main; # root /usr/local/apache-tomcat-7.0.52/webapps/smdemo/; location / { index index_tel.jsp index.jsp index.html index.htm ; 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_buffers 32 4k; proxy_connect_timeout 3; proxy_send_timeout 30; proxy_read_timeout 30; proxy_pass http://127.0.0.1:8080; } } } 我使用的是nginx的默认文件,有这俩个地方的修改:
1、server_name
把server_name 修改成你申请的域名就可以了,配置daxiao123.com是为了用户不输入www时也能正常访问到网站,
不配的话有些浏览器不会默认加上。
2、proxy_pass
proxy_pass 配置的是tomcat的服务地址(ip+端口),因为我部署在本地,所以是127.0.0.1,你按你的ip地址和端口配就行。这些配置修改完后,进入nginx安装目录使用命令重启
./sbin/nginx -s reload
重启成功后,访问下网站看是否已经成功了,如果过程中出现问题无法解决,欢迎大家进群讨论(624135994)