博客
关于我
OpenShift 4 之使用https协议访问Route
阅读量:330 次
发布时间:2019-03-04

本文共 1012 字,大约阅读时间需要 3 分钟。

《》

说明:本文已经在OpenShift 4.6环境中验证

使用OpenShift的oc命令可以将Service内部访问转为(oc的expose子命令)可从外部访问的Route,这种转换缺省是使用http协议访问应用的。如果要支持https协议,除了需要生成证书外,还需要用“oc create route”来创建Route对象。

  1. 首先部署一个测试应用
$ oc new-project https$ oc new-app openshift/hello-openshift
  1. 生成访该hello应用的FQDN名称。
$ HELLO_HOSTNAME=hello.$(oc get ingresscontroller default -n openshift-ingress-operator -o jsonpath='{.status.domain}')
  1. 创建访问FQDN地址的SSL密钥和证书。
$ openssl req -newkey rsa:4096 -nodes -sha256 -keyout example.key -x509 -days 365 -out example.crt -subj "/C=CN/ST=BEIJING/L=BJ/O=REDHAT/OU=IT/CN=${HELLO_HOSTNAME}"

注意:FQDN长度不能超过64个字符,否则会报下面错误。

140559095121728:error:0D07A097:asn1 encoding routines:ASN1_mbstring_ncopy:string too long:crypto/asn1/a_mbstr.c:107:maxsize=64
  1. 根据密钥、证书和Service创建Route,并指定访问的FQDN
$ oc create route edge --service=hello-openshift --hostname=${HELLO_HOSTNAME} --key=example.key --cert=example.crt
  1. 用https协议访问Route
$ curl --cacert example.crt https://$(oc get route hello-openshift -o template --template '{    {.spec.host}}')Hello OpenShift!

转载地址:http://relh.baihongyu.com/

你可能感兴趣的文章
nginx+php的搭建
查看>>
Nginx+Redis+Ehcache:大型高并发与高可用的三层缓存架构总结
查看>>
nginx+tomcat+memcached
查看>>
nginx+tomcat单个域名及多个域名配置
查看>>
Nginx+Tomcat实现动静分离
查看>>
nginx+Tomcat性能监控
查看>>
nginx+uwsgi+django
查看>>
nginx+vsftp搭建图片服务器
查看>>
Nginx-http-flv-module流媒体服务器搭建+模拟推流+flv.js在前端html和Vue中播放HTTP-FLV视频流
查看>>
nginx-vts + prometheus 监控nginx
查看>>
Nginx/Apache反向代理
查看>>
Nginx: 413 – Request Entity Too Large Error and Solution
查看>>
nginx: [emerg] getpwnam(“www”) failed 错误处理方法
查看>>
nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:
查看>>
nginx: [error] open() “/usr/local/nginx/logs/nginx.pid“ failed (2: No such file or directory)
查看>>
nginx:Error ./configure: error: the HTTP rewrite module requires the PCRE library
查看>>
Nginx:objs/Makefile:432: recipe for target ‘objs/src/core/ngx_murmurhash.o‘解决方法
查看>>
nginxWebUI runCmd RCE漏洞复现
查看>>
nginx_rtmp
查看>>
Vue中向js中传递参数并在js中定义对象并转换参数
查看>>