操作系统 : cent Os 7
虚拟机上用tomcat跑了一个web项目,端口8001
虚拟机IP:192.168.168.144
在主机上可以通过 192.168.168.144:8001/web访问该项目。
请教如何配置nginx , 可以实现在 主机上 通过 www.mywebtest.com访问到该web项目?
呃,自己搞了半天。nginx都启不起来。。
配置文件如下:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
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 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
server{
listen 192.168.168.144:8001;
server_name www.mywebtest.com;
location / {
root web;
}
}
}
修改主机上的hosts文件,配置域名映射关系,把 www.mywebtest.com 映射到192.168.168.144