`
Franciswmf
  • 浏览: 780285 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

nginx配置:部署spring cloud项目、spring boot项目

 
阅读更多
1、运行jar包
运行:nohup java -jar crm_test.jar > crm_test.log 2>&1 &
查看日志:
tail -f crm_test.log


2、配置nginx.conf

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  120;

    server {
        listen       8888; #需要开通外网访问的端口,下面的端口不需要,只要不被占用,可以任意使用 lsof -i:9100
        server_name  10.100.211.88;
		client_max_body_size 50m;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location /OA {
            root   html;
            index  index.html index.htm;
			proxy_pass http://10.100.211.88:8098/OA; #单体应用 OA测试项目
        }
		
		location /crmBoot {
            root   html;
            index  index.html;
			proxy_set_header  Host $http_host;
            proxy_set_header  X-Real-IP        $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
			proxy_pass http://10.100.211.88:9100/crm/; #spring boot测试项目
        }
		#8902为spring cloud架构的网关服务
		location /cloudWeb {
            root   html;
            index  index.html;
			proxy_set_header  Host $http_host;
            proxy_set_header  X-Real-IP        $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
			proxy_pass http://10.100.211.88:8902/cloudWeb/; #spring cloud微应用测试 web
        }
		location /cloudLogin {
            root   html;
            index  index.html;
			proxy_set_header  Host $http_host;
            proxy_set_header  X-Real-IP        $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
			proxy_pass http://10.100.211.88:8902/cloudLogin/; #spring cloud微应用测试 登录登出
        }
		location /cloudSystem {
            root   html;
            index  index.html;
			proxy_set_header  Host $http_host;
            proxy_set_header  X-Real-IP        $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
			proxy_pass http://10.100.211.88:8902/cloudSystem/; #spring cloud微应用测试 系统管理
        }
		location /cloudCrm {
            root   html;
            index  index.html;
			proxy_set_header  Host $http_host;
            proxy_set_header  X-Real-IP        $remote_addr;
            proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
			proxy_pass http://10.100.211.88:8902/cloudCrm/; #spring cloud微应用测试 核心业务
        }
		
        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
		......此处省略多行
    }

}


3、nginx启动、停止、重启、测试配置文件nginx.conf
cd /usr/nginx/

停止: sbin/nginx -s stop
启动:sbin/nginx
重启:sbin/nginx -s reload
测试nginx.conf文件是否配置正确: sbin/nginx -t



4、linux服务器上直接调用已发布的服务接口
get请求:
  curl -v "http://10.100.211.88:8888/crmBoot/student/getAll"
post请求:
  curl -i -k  -H "Content-type: application/json;charset=UTF-8" -X POST -d '{"stuId":"6", "stuName":"mu"}' "http://10.100.211.88:8888/crmBoot/student/pageList"

Linux上模拟get和post请求
1、get请求
1.1 使用curl命令
curl -v http://127.0.0.1:80/xcloud/test?version=1\&client_version=1.1.0\&seq=1001\&host=aaa.com
或者
curl -v "http://127.0.0.1:80/xcloud/test?version=1&client_version=1.1.0&seq=1001&host=aaa.com"  //控制台打印

1.2 使用wget命令
wget  "http://www.baidu.com" //把结果保存为一个文件

2、post请求
2.1 使用curl命令
//使用curl命令,通过-d参数,把访问参数放在里面,如果没有参数,则不需要-d,
curl -d "username=user1&password=123" "www.test.com/login"

2.2 使用wget命令
wget –post-data 'username=user1&password=123' http://www.baidu.com

2.3 发送格式化json请求
curl -i -k  -H "Content-type: application/json" -X POST -d '{"version":"6.6.0", "from":"mu", "product_version":"1.1.1.0"}' https://10.10.10.10:80/test

3、curl和wget比较
3.1 curl和wget区别
curl模拟的访问请求一般直接在控制台显示,而wget则把结果保存为一个文件。
如果结果内容比较少,需要直接看到结果可以考虑使用curl进行模拟请求,如果返回结果比较多,则可考虑wget进行模拟请求。
3.2 curl命令
curl "http://www.baidu.com"  如果这里的URL指向的是一个文件或者一幅图都可以直接下载到本地
curl -i "http://www.baidu.com"  显示全部信息
curl -I "http://www.baidu.com"  只显示头部信息
curl -v "http://www.baidu.com"   显示get请求全过程解析

其它博客:
https://www.cnblogs.com/kaleidoscope/p/9719841.html
https://blog.csdn.net/php_younger/article/details/76147060
博客01:
一、get请求
curl "www.baidu.com"
二、post请求
curl -d "param1=value1&param2=value2" "http://www.baidu.com"
三 携带报文头
curl  -i "www.baidu.com"

博客02:
Http请求的是客户端向服务器的请求消息,Http请求主要分为get或post两种,在linux系统下可以用curl和wget命令来模拟Http的请求。
一、curl模拟请求
1、get请求:
    curl “http://www.baidu.com” 如果这里的URL指向的是一个文件或者一幅图都可以直接下载到本地
  curl -i “http://www.baidu.com” 显示全部信息
  curl -l “http://www.baidu.com” 只显示头部信息
  curl -v “http://www.baidu.com” 显示get请求全过程解析
2、post请求:
     curl -d “param1=value1&m2=value2” “http://www.baidu.com”
二、wget模拟请求
1、get请求:
     wget “http://www.baidu.com”也可以
2、post请求:
     wget --post-data ‘user=foo&password=bar’ http://www.baidu.com

5、解决nginx/logs/error.log报的权限问题: nginx/proxy_temp permission denied
chmod -R 777   *   --改变文件或文件夹的权限(读、写、执行)
chown -R user:user   *  --改变文件或文件夹的归属
root重启nginx服务如果遇到文件或文件夹归属重置的问题,可以考虑用user用户来启动nginx服务。
su
sbin/nginx -s stop 停止
su user
sbin/nginx 启动
sbin/nginx -s reload 重启
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics