{"id":18559072,"url":"https://github.com/linux-china/http2-java-demo","last_synced_at":"2025-04-10T02:30:38.984Z","repository":{"id":136595495,"uuid":"48152082","full_name":"linux-china/http2-java-demo","owner":"linux-china","description":"Spring Boot with HTTP/2","archived":false,"fork":false,"pushed_at":"2025-03-15T16:17:03.000Z","size":54,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T02:51:10.490Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linux-china.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-12-17T04:22:30.000Z","updated_at":"2025-03-15T16:17:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"4e1c7baf-e893-4101-b84c-070200a53458","html_url":"https://github.com/linux-china/http2-java-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Fhttp2-java-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Fhttp2-java-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Fhttp2-java-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linux-china%2Fhttp2-java-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linux-china","download_url":"https://codeload.github.com/linux-china/http2-java-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248144157,"owners_count":21054876,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T21:41:59.086Z","updated_at":"2025-04-10T02:30:38.975Z","avatar_url":"https://github.com/linux-china.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"HTTP 2.0 Server Demo\n=========================\n\nSpring Boot App with HTTP/2 enabled\n\n### HTTP Client\n\n* OkHttp3 4.4.0: https://square.github.io/okhttp/\n* httpcomponents-client-5: https://hc.apache.org/httpcomponents-client-5.0.x/index.html\n\n### User mkcert to produce pkcs12 keystore file\n\n```\nmkcert -pkcs12 localhost\n```\n\n### HTTP/2 over TCP (h2c)\n\nAll four embedded web containers now support HTTP/2 over TCP (h2c) without any manual customization.\nTo enable h2c, set `server.http2.enabled` is true and leave `server.ssl.enabled` set to false (its default value).\n\nCaddy Server reverse_proxy configuration:\n\n```\nreverse_proxy {\n    to http://127.0.0.1:2012\n    transport http {\n        versions h2c\n    }\n}\n```\n\n### UDS support - Unix Domain Sockets\n\n* Add dependency\n\n```xml\n       \u003cdependency\u003e\n            \u003cgroupId\u003eio.netty\u003c/groupId\u003e\n            \u003cartifactId\u003enetty-transport-native-kqueue\u003c/artifactId\u003e\n            \u003cversion\u003e${netty.version}\u003c/version\u003e\n            \u003cclassifier\u003eosx-x86_64\u003c/classifier\u003e\n        \u003c/dependency\u003e\n```\n\n* Create NettyUdsConfig.java\n\n```java\nimport io.netty.channel.unix.DomainSocketAddress;\nimport org.springframework.boot.web.embedded.netty.NettyReactiveWebServerFactory;\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.context.annotation.Configuration;\n\nimport java.util.Collections;\n\n/**\n * Netty UDS configuration\n */\n@Configuration\npublic class NettyUdsConfig {\n\n    @Bean\n    public NettyReactiveWebServerFactory factory() {\n        NettyReactiveWebServerFactory factory = new NettyReactiveWebServerFactory();\n        factory.setServerCustomizers(Collections.singletonList(httpServer -\u003e httpServer.bindAddress(() -\u003e new DomainSocketAddress(\"/tmp/test.sock\"))));\n        return factory;\n    }\n}\n```\n* Start server and test\n\n```\ncurl -GET --unix-socket /tmp/test.sock http://localhost/\n```\n\n### Reference\n\n* Spring Boot SSL: https://docs.spring.io/spring-boot/docs/3.1.0/reference/html/features.html#features.ssl\n* HTTP 2.0 specification: https://http2.github.io\n* mkcert: https://github.com/FiloSottile/mkcert\n* HttpCore 5.0 Examples: https://hc.apache.org/httpcomponents-core-5.0.x/examples.html\n* HTTP/2 in Netty: https://www.baeldung.com/netty-http2\n* How I can tell alias of the wanted key-entry to SSLSocket before connecting? https://stackoverflow.com/questions/15201251/how-i-can-tell-alias-of-the-wanted-key-entry-to-sslsocket-before-connecting\n* tls demo:  https://github.com/linux-china/tls-demo\n* Spring SSL: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#howto.webserver.configure-ssl\n* Three Ways to Run Your Java Locally with HTTPS: https://developer.okta.com/blog/2022/01/31/local-https-java\n* Reload SSL Certificates From HashiCorp Vault for Spring Boot: https://www.baeldung.com/spring-boot-hashicorp-valut-reload-ssl-certificates\n* Enable HTTP2 with Tomcat in Spring Boot: https://www.baeldung.com/spring-boot-http2-tomcat\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinux-china%2Fhttp2-java-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinux-china%2Fhttp2-java-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinux-china%2Fhttp2-java-demo/lists"}