一:  tomcat直接配置域名:https://blog.csdn.net/qq_36330228/article/details/78516160

二: 使用nginx进行反向代理  

   tomcat服务的访问端口为8081,通过nginx配置域名并指向8081端口服务

  nginx配置文件(./conf/nginx.conf)如下:  安装nginx可参考:https://www.cnblogs.com/mufengforward/p/9342354.html

#user  nobody;
worker_processes ; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections ;
} 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 ;
keepalive_timeout ; #gzip on; server {
listen ;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm;
} #error_page /.html; # redirect server error pages to the static page /50x.html
#
error_page /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# 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;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen ;
# listen somename:;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} #个人网站        ----------以下是我所添加的使用到的配置
server {
listen ;
server_name www.feng16.com;
location / {
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_pass http://127.0.0.1:8081;
}
error_page /50x.html;
location = /50x.html {
root html;
}
} }

  以下是对应的tomcat配置(./conf/server.xml)文件中的访问端口:     具体的配置文件解析可参考:https://www.cnblogs.com/mufengforward/p/9444495.html

  

  启动tomcat服务正常运行,修改完配置文件后重启nginx,便可以访问了:www.mufengforward.com

  linux重启命令:nginx -s reload

https://www.cnblogs.com/naaoveGIS/p/5478208.html

java项目配置域名(tomcat直接配置 or 使用nginx反向代理)的更多相关文章

  1. [svc]tomcat目录结构/虚拟主机/nginx反向代理cache配置

    tomcat目录文件 /usr/local/tomcat/bin/catalina.sh stop sleep 3 /usr/local/tomcat/bin/catalina.sh start to ...

  2. nginx 反向代理配置(一)

    文章参考:https://blog.csdn.net/physicsdandan/article/details/45667357       什么是代理?       代理在普通生活中的意义就是本来 ...

  3. Tomcat多个项目部署,通过Nginx反向代理分别配置二级域名的流程

    购买域名.示例:example.com 设置多个二级域名.如图: 配置tomcat文件: 修改tomcat/conf目录下的server.xml文件: 如下配置配置了3个容器,使用三个不同的端口. 请 ...

  4. node项目发布+域名及其二级域名配置+nginx反向代理+pm2

    学习node的时候也写了一些demo.但是只是限于本地测试,从来没有发布.今天尝试发布项目. 需要准备的东西 node 项目:为了突出重点,说明主要问题.我只是拿express 写了很简单的demo. ...

  5. [亲测]ASP.NET Core 2.0怎么发布/部署到Ubuntu Linux服务器并配置Nginx反向代理实现域名访问

    前言 ASP.NET Core 2.0 怎么发布到Ubuntu服务器?又如何在服务器上配置使用ASP.NET Core网站绑定到指定的域名,让外网用户可以访问呢? 步骤 第1步:准备工作 一台Liun ...

  6. [亲测]七步学会ASP.NET Core 2.0怎么发布/部署到Ubuntu Linux服务器并配置Nginx反向代理实现域名访问

    前言 ASP.NET Core 2.0 怎么发布到Ubuntu服务器?又如何在服务器上配置使用ASP.NET Core网站绑定到指定的域名,让外网用户可以访问呢? 步骤 第1步:准备工作 一台Liun ...

  7. centos LAMP第二部分apache配置 下载discuz!配置第一个虚拟主机 安装Discuz! 用户认证 配置域名跳转 配置apache的访问日志 配置静态文件缓存 配置防盗链 访问控制 apache rewrite 配置开机启动apache tcpdump 第二十节课

    centos    LAMP第二部分apache配置  下载discuz!配置第一个虚拟主机 安装Discuz! 用户认证 配置域名跳转  配置apache的访问日志  配置静态文件缓存  配置防盗链 ...

  8. Nginx证书配置:tomcat证书jks文件转nginx证书.cet和key文件

    Nginx证书配置:tomcat证书jks文件转nginx证书.cet和key文件1.查看jks文件中的entry. keytool -list -keystore server.jks Enter ...

  9. Linux下nginx反向代理服务器安装与配置实操

    1.我们只要实现访问nginx服务器能跳转到不同的服务器即可,我本地测试是这样的, 在nginx服务器里面搭建了2个tomcat,2个tomcat端口分别是8080和8081,当我输入我nginx服务 ...

  10. Nginx反向代理配置可跨域

    由于业务需要,同一项目中的前端代码放在静态环境中,而后端代码放在tomcat中,但此时问题却出现了:前端使用ajax请求后端获取数据时出现如下报错 XMLHttpRequest cannot load ...

随机推荐

  1. oracle 锁表查看与解锁

    查看被锁的表: select l.session_id,o.owner,o.object_name from v$locked_object l,dba_objects o where l.objec ...

  2. jquery 特效

    http://demo.howtoexe.com/instagram-gravity-gallery/index.html

  3. 纯css实现网络图标

    <html> <head> <title>css图标</title> <meta charset="utf-8"> &l ...

  4. RGB,YCBCR在HDMI传输线是数据排列

    RGB4:4:4 YCbCr4:4:4 YCbCr4:2:2 YCbCr4:2:0

  5. 通过sftp操作Linux服务器上的文件(java)

    本文为实现对linux服务器文件的操作.windows服务器不支持. 引入jar包:jsch-0.1.42.jar package com.csvreader.sftp; import java.io ...

  6. Jersey RESTful WebService框架学习(六)接收MultivaluedMap类型参数

    现在的web开发中有些工程会觉得实体bean的架构会比较重,现在的持久层的框架的特点也层出不穷,核心思想的ORM在此基础上,提供了很多便捷操作,mybatis,jfinal(内部持久层框架)之类的也诞 ...

  7. 【慕课网实战】Spark Streaming实时流处理项目实战笔记四之铭文升级版

    铭文一级: 需求二:Agent选型:exec source + memory channel + logger sink# Name the components on this agenta1.so ...

  8. Failed to place enough replicas

    如果DataNode的dfs.datanode.data.dir全配置成SSD类型,则执行"hdfs dfs -put /etc/hosts hdfs:///tmp/"时会报如下错 ...

  9. POJ3320 Jessica's Reading Problem 2017-05-25 19:55 38人阅读 评论(0) 收藏

    Jessica's Reading Problem Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12346   Accep ...

  10. jQuery插件初级练习3

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...