{"id":848,"date":"2018-06-04T18:56:23","date_gmt":"2018-06-04T09:56:23","guid":{"rendered":"http:\/\/www.freesens.com\/x\/?p=848"},"modified":"2018-06-04T18:56:23","modified_gmt":"2018-06-04T09:56:23","slug":"how-set-up-spring-boot-to-run-http-https-ports","status":"publish","type":"post","link":"http:\/\/www.freesens.com\/x\/?p=848","title":{"rendered":"How set up Spring Boot to run HTTP\/HTTPS ports"},"content":{"rendered":"<p>Spring Boot. \uc798 \ubaa8\ub984.<br \/>\n\uc0c8\ub85c \ud22c\uc785\ub418\ub294 \ud504\ub85c\uc81d\ud2b8\uc5d0\uc11c Spring Boot\ub85c \ud504\ub85c\uc81d\ud2b8 \uad6c\uc131\ud558\uc5ec \uc0ac\uc6a9\uc911\uc778\ub370, http\ub85c \uc791\uc5c5\ud558\ub2e4\uac00 \uc77c\ubd80 \ud654\uba74\uc774 https\uc801\uc6a9\uc774 \ud544\uc694\ud558\uc5ec \ub85c\uceec \uac1c\ubc1c\ud658\uacbd\uc5d0\uc11c spring boot\uae30\ubc18\uc73c\ub85c http\/https\ub97c \ub3d9\uc2dc\uc5d0 \ub744\uc6cc\uc57c \ud558\ub294 \uc0c1\ud669\uc774 \ubc1c\uc0dd.<\/p>\n<p>\uc77c\ub2e8 \uc548\uc368\ubcf8 \uac83\uc774\ub77c\uc11c \uc798 \ubaa8\ub984&#8230;\u314e\u314e<br \/>\nSpring Boot\ub85c \uc14b\ud305\ub41c \ud504\ub85c\uc81d\ud2b8 \uc790\uccb4\uac00 \ucc98\uc74c\uc778\uc9c0\ub77c&#8230;<br \/>\n\uc77c\ub2e8 yaml&#8230;..\uc57c\ubb3c\uc740 \ub610 \ubb50\ub798?\u00a0 \ub77c\uba74\uc11c \uac80\uc0c9.<br \/>\n\uc5ec\uae30\uc11c\ub294 \uad73\uc774 yaml\uc774 \ubb54\uc9c0 \ub17c\uc678\ub77c\uc11c \ud328\uc2a4.<\/p>\n<p>application.yaml\uc5d0 \uc544\ub798\uc640 \uac19\uc774 \uc124\uc815\ub418\uc5b4 \uc788\uc5c8\ub294\ub370, \uc544\ub798\uc640 \uac19\uc774 \uc218\uc815.<\/p>\n<pre>server:\r\n  port: 80<\/pre>\n<pre>server:\r\n  port: 443\r\n  ssl:\r\n      enabled: true\r\n      key-alias: server\r\n      key-store: \"\/~pathname~\/keyStoreFile.jks\"\r\n      key-store-password: \"keyStorePassword\"\r\n  http:\r\n    port: 80<\/pre>\n<p>https \uc124\uc815\uc744 \uc704\ud55c \uc0ac\uc124\uc778\uc99d\uc11c \uc0dd\uc131\uc740 \uc544\ub798 link \ucc38\uc870.<br \/>\n<a href=\"https:\/\/www.digicert.com\/easy-csr\/keytool.htm\" target=\"_blank\" rel=\"noopener\">Java Keytool CSR Creation<\/a><\/p>\n<p>detail\ud558\uac8c \uc704\uc758 \ub9c1\ud06c\ub97c \ubaa8\ub450 \uc77d\uc5b4 \ubcfc \ud544\uc694\ub294 \uc5c6\uace0, \uacfc\uac70 open-ssl\ub85c \uc791\uc5c5\ud588\ub358\uac70\ubcf4\ub2e4 \uac04\ub2e8.<br \/>\n\uc704 \ub9c1\ud06c\uc758 \uc0c1\ub2e8 ssl\uc778\uc99d\uc11c \uc0dd\uc131\uc6a9 \uae30\ubcf8\uc815\ubcf4 \uc785\ub825 \ud6c4 Generate \ubc84\ud2bc\uc744 \ub204\ub974\uba74 \uc6b0\uce21\uc5d0 \uba85\ub839\uc5b4\uac00 \uc0dd\uc131\ub428.<br \/>\n\uadf8\uac78 \ubcf5\uc0ac\ud574\uc11c&#8230;. \ubcf8\uc778 \uac1c\ubc1c\ud658\uacbd\uc758 jdk\uc124\uce58\uacbd\ub85c\/bin\/ \ub514\ub809\ud1a0\ub9ac \ud558\uc704\uc5d0\uc11c \ud574\ub2f9 \uba85\ub839\uc5b4\ub97c \uc2e4\ud589\ud558\uba74 \ub428.<br \/>\npath\uc5d0 jdk\uacbd\ub85c\ub97c \uc7a1\uc544\ub454 \uc0c1\ud0dc\ub77c\uba74 \uadf8\ub0e5 keytool \uc774\ub77c\uace0 \uc785\ub825\ud574\uc11c \uc544\ubb34\ub370\uc11c\ub098 \uc2e4\ud589\ud574\ub3c4 \ub420\ub4ef&#8230;.<br \/>\n\uc2e4\ud589 \ud6c4 \ube44\ubc00\ubc88\ud638 \uc785\ub825\ud558\ub77c\uace0 \ub098\uc624\uba74&#8230;.\uc5ec\ub7ec\ubc88 \uac19\uc740 \ube44\ubc00\ubc88\ud638\ub85c \uc785\ub825 \ud588\uc73c\ub54c, \ucd5c\uc885\uc801\uc73c\ub85c *.csr \/ *.jks \ud30c\uc77c\uc774 \uc0dd\uc131\ub418\uace0, jks\ud30c\uc77c\uc744 \uc704\uc758 \uc124\uc815\uc5d0\uc11c key-store\uc5d0\u00a0 \uacbd\ub85c\ub85c \uc785\ub825\ud558\uace0, \uc9c0\uc815\ud55c \ube44\ubc00\ubc88\ud638\ub294 key-store-password\uc5d0 \uc785\ub825.<\/p>\n<p>https 443\ud3ec\ud2b8\ub97c \uae30\ubcf8\uc73c\ub85c \ub744\uc6b0\uace0, http 80\uc740 server.http.port\ud615\ud0dc\ub85c \uc815\uc758.<\/p>\n<p>\uc11c\ubc84 \uad6c\ub3d9\uc2dc https 443\ud3ec\ud2b8\ub97c \uae30\ubcf8\uc73c\ub85c \uad6c\ub3d9\ud558\uba70\u00a0 http\ub294 spring boot\uac00 \uc5b4\ub178\ud14c\uc774\uc158 \uae30\ubc18\uc758 Configuration\uc744 \uc77d\uc5b4\uc11c 80 port\ub85c \uad6c\ub3d9\ud558\ub3c4\ub85d \uc544\ub798\uc640 \uac19\uc740 class\ub97c \ucd94\uac00. (\ub2f9\uc5f0\ud788 spring component-scan\uc774 \uc774\ub8e8\uc5b4\uc9c0\ub294 package\uc5d0 \ub9cc\ub4e4\uc5b4\uc57c&#8230;.)<\/p>\n<pre>package com.freesens.projectname;\r\n\r\nimport org.apache.catalina.connector.Connector;\r\nimport org.springframework.beans.factory.annotation.Value;\r\nimport org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;\r\nimport org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;\r\nimport org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;\r\nimport org.springframework.context.annotation.Bean;\r\nimport org.springframework.context.annotation.Configuration;\r\n\r\n@Configuration\r\npublic class TomcatConfig {\r\n\r\n    @Value(\"${server.http.port}\")\r\n    private int httpPort;\r\n    @Bean\r\n    public EmbeddedServletContainerCustomizer containerCustomizer() {\r\n        return new EmbeddedServletContainerCustomizer() {\r\n            @Override\r\n            public void customize(ConfigurableEmbeddedServletContainer container) {\r\n                if (container instanceof TomcatEmbeddedServletContainerFactory) {\r\n                    TomcatEmbeddedServletContainerFactory containerFactory =\r\n                            (TomcatEmbeddedServletContainerFactory) container;\r\n\r\n                    Connector connector = new Connector(TomcatEmbeddedServletContainerFactory.DEFAULT_PROTOCOL);\r\n                    connector.setPort(httpPort);\r\n                    containerFactory.addAdditionalTomcatConnectors(connector);\r\n                }\r\n            }\r\n        };\r\n    }\r\n}<\/pre>\n<p>\uc124\uc815 \ub05d\ub0ac\uc73c\uba74 \uc11c\ubc84 \uad6c\ub3d9\ud558\uace0, http\/https\ub85c \uac01\uac01 \ud638\ucd9c\ud558\uc5ec \uc815\uc0c1 \uc791\ub3d9\uc5ec\ubd80 \ud655\uc778\ud558\uba74 \ub05d.<\/p>\n<p>http:\/\/www.hostname.com\/path.do<br \/>\nhttps:\/\/www.hostname.com\/path.do<\/p>\n<p>&nbsp;<\/p>\n<p>\ucc38\uace0 \ub9c1\ud06c.<br \/>\n&#8211;\u00a0<a href=\"http:\/\/nemerosa.ghost.io\/2015\/07\/25\/enabling-ssl-with-spring-boot-going-real\/\" target=\"_blank\" rel=\"noopener\">enabling-ssl-with-spring-boot-going-real<\/a><br \/>\n&#8211;\u00a0<a href=\"https:\/\/stackoverflow.com\/questions\/30896234\/how-set-up-spring-boot-to-run-https-http-ports\" target=\"_blank\" rel=\"noopener\">how-set-up-spring-boot-to-run-https-http-ports<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\uc5ed\uc2dc \uac80\uc0c9\uc744 \uc798\ud574\uc57c &#8230;&#8230;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring Boot. \uc798 \ubaa8\ub984. \uc0c8\ub85c \ud22c\uc785\ub418\ub294 \ud504\ub85c\uc81d\ud2b8\uc5d0\uc11c Spring Boot\ub85c \ud504\ub85c\uc81d\ud2b8 \uad6c\uc131\ud558\uc5ec \uc0ac\uc6a9\uc911\uc778\ub370, http\ub85c \uc791\uc5c5\ud558\ub2e4\uac00 \uc77c\ubd80 \ud654\uba74\uc774 https\uc801\uc6a9\uc774 \ud544\uc694\ud558\uc5ec \ub85c\uceec \uac1c\ubc1c\ud658\uacbd\uc5d0\uc11c spring boot\uae30\ubc18\uc73c\ub85c http\/https\ub97c \ub3d9\uc2dc\uc5d0 \ub744\uc6cc\uc57c \ud558\ub294 \uc0c1\ud669\uc774 \ubc1c\uc0dd. \uc77c\ub2e8 \uc548\uc368\ubcf8 \uac83\uc774\ub77c\uc11c \uc798 \ubaa8\ub984&#8230;\u314e\u314e Spring Boot\ub85c \uc14b\ud305\ub41c \ud504\ub85c\uc81d\ud2b8 \uc790\uccb4\uac00 \ucc98\uc74c\uc778\uc9c0\ub77c&#8230; \uc77c\ub2e8 yaml&#8230;..\uc57c\ubb3c\uc740 \ub610 \ubb50\ub798?\u00a0 \ub77c\uba74\uc11c \uac80\uc0c9. \uc5ec\uae30\uc11c\ub294 \uad73\uc774 yaml\uc774 \ubb54\uc9c0 \ub17c\uc678\ub77c\uc11c \ud328\uc2a4. application.yaml\uc5d0 \uc544\ub798\uc640 \uac19\uc774 \uc124\uc815\ub418\uc5b4 &hellip; <a href=\"http:\/\/www.freesens.com\/x\/?p=848\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How set up Spring Boot to run HTTP\/HTTPS ports<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,13],"tags":[267,266,291,270,290],"class_list":["post-848","post","type-post","status-publish","format-standard","hentry","category-development","category-java","tag-http","tag-https","tag-spring-boot","tag-ssl","tag-290"],"_links":{"self":[{"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=\/wp\/v2\/posts\/848","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=848"}],"version-history":[{"count":1,"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=\/wp\/v2\/posts\/848\/revisions"}],"predecessor-version":[{"id":849,"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=\/wp\/v2\/posts\/848\/revisions\/849"}],"wp:attachment":[{"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=848"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=848"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.freesens.com\/x\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=848"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}