├── .gitignore ├── .idea └── runConfigurations │ ├── Start_nginx_admin.xml │ ├── Start_nginx_agent.xml │ └── nginx_admin__install__DskipTests_true_.xml ├── .mvn └── wrapper │ ├── MavenWrapperDownloader.java │ └── maven-wrapper.properties ├── .travis.yml ├── LICENSE.txt ├── README.md ├── build.bat ├── build.sh ├── docs ├── images │ ├── dashboard-page.png │ ├── goto-virtual-host-config.png │ ├── login.png │ ├── nginx-agent-config.png │ ├── nginx-nodes.png │ ├── select-agent-session.png │ ├── upstream-config.png │ └── virtual-host-config.png ├── install_nginx_admin_guide.md ├── install_nginx_in_centos_6.md ├── nginx-admin-plus-manual.md └── nginx_configuration_guide.md ├── install ├── install-nginx-admin-agent.sh └── install-nginx-admin-ui.sh ├── mvnw ├── mvnw.cmd ├── nginx-admin-agent-client ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── jslsolucoes │ │ │ └── nginx │ │ │ └── admin │ │ │ └── agent │ │ │ └── client │ │ │ ├── NginxAgentClient.java │ │ │ ├── NginxAgentClientBuilder.java │ │ │ ├── RestClient.java │ │ │ └── api │ │ │ ├── NginxAgentClientApi.java │ │ │ ├── NginxAgentClientApiBuilder.java │ │ │ ├── NginxAgentClientApis.java │ │ │ └── impl │ │ │ ├── DefaultNginxAgentClientApi.java │ │ │ ├── HttpHeader.java │ │ │ ├── access │ │ │ └── log │ │ │ │ ├── NginxAccessLog.java │ │ │ │ └── NginxAccessLogBuilder.java │ │ │ ├── cli │ │ │ ├── NginxCommandLineInterface.java │ │ │ └── NginxCommandLineInterfaceBuilder.java │ │ │ ├── configure │ │ │ ├── NginxConfigure.java │ │ │ └── NginxConfigureBuilder.java │ │ │ ├── error │ │ │ └── log │ │ │ │ ├── NginxErrorLog.java │ │ │ │ └── NginxErrorLogBuilder.java │ │ │ ├── importation │ │ │ ├── NginxImport.java │ │ │ └── NginxImportBuilder.java │ │ │ ├── info │ │ │ ├── NginxServerInfo.java │ │ │ └── NginxServerInfoBuilder.java │ │ │ ├── os │ │ │ ├── NginxOperationalSystemInfo.java │ │ │ └── NginxOperationalSystemInfoBuilder.java │ │ │ ├── ping │ │ │ ├── NginxPing.java │ │ │ └── NginxPingBuilder.java │ │ │ ├── ssl │ │ │ ├── NginxSsl.java │ │ │ └── NginxSslBuilder.java │ │ │ ├── status │ │ │ ├── NginxStatus.java │ │ │ └── NginxStatusBuilder.java │ │ │ ├── upstream │ │ │ ├── NginxUpstream.java │ │ │ └── NginxUpstreamBuilder.java │ │ │ └── virtual │ │ │ └── host │ │ │ ├── NginxVirtualHost.java │ │ │ └── NginxVirtualHostBuilder.java │ └── resources │ │ └── META-INF │ │ └── beans.xml │ └── test │ └── java │ └── com │ └── jslsolucoes │ └── nginx │ └── admin │ └── agent │ └── client │ ├── NginxCommandLineInterfaceTest.java │ ├── NginxConfigureTest.java │ ├── NginxOperationSystemInfoTest.java │ ├── NginxPingTest.java │ ├── NginxServerInfoTest.java │ ├── NginxStatusTest.java │ └── NginxUpstreamTest.java ├── nginx-admin-agent-configuration ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── jslsolucoes │ └── nginx │ └── admin │ └── agent │ └── config │ ├── Application.java │ ├── Configuration.java │ ├── ConfigurationLoader.java │ ├── Nginx.java │ └── Server.java ├── nginx-admin-agent-model ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── jslsolucoes │ └── nginx │ └── admin │ └── agent │ └── model │ ├── Endpoint.java │ ├── FileObject.java │ ├── FileObjectBuilder.java │ ├── Location.java │ ├── request │ ├── NginxConfigureRequest.java │ ├── NginxImportConfRequest.java │ ├── ssl │ │ ├── NginxSslCreateRequest.java │ │ └── NginxSslUpdateRequest.java │ ├── upstream │ │ ├── NginxUpstreamCreateRequest.java │ │ └── NginxUpstreamUpdateRequest.java │ └── virtual │ │ └── host │ │ ├── NginxVirtualHostCreateRequest.java │ │ └── NginxVirtualHostUpdateRequest.java │ └── response │ ├── NginxAuthenticationFailResponse.java │ ├── NginxCommandLineInterfaceResponse.java │ ├── NginxConfigureResponse.java │ ├── NginxExceptionResponse.java │ ├── NginxImportConfResponse.java │ ├── NginxIndexResponse.java │ ├── NginxOperationalSystemInfoResponse.java │ ├── NginxPingResponse.java │ ├── NginxResponse.java │ ├── NginxServerInfoResponse.java │ ├── NginxStatusResponse.java │ ├── access │ └── log │ │ ├── NginxAccessLogCollectResponse.java │ │ └── NginxAccessLogRotateResponse.java │ ├── error │ └── log │ │ ├── NginxErrorLogCollectResponse.java │ │ └── NginxErrorLogRotateResponse.java │ ├── ssl │ ├── NginxSslCreateResponse.java │ ├── NginxSslDeleteResponse.java │ ├── NginxSslReadResponse.java │ └── NginxSslUpdateResponse.java │ ├── upstream │ ├── NginxUpstreamCreateResponse.java │ ├── NginxUpstreamDeleteResponse.java │ ├── NginxUpstreamReadResponse.java │ └── NginxUpstreamUpdateResponse.java │ └── virtual │ └── host │ ├── NginxVirtualHostCreateResponse.java │ ├── NginxVirtualHostDeleteResponse.java │ ├── NginxVirtualHostReadResponse.java │ └── NginxVirtualHostUpdateResponse.java ├── nginx-admin-agent-standalone ├── assembly │ └── full.xml ├── nginx-admin-agent │ ├── conf │ │ └── nginx-admin-agent.conf │ ├── log │ │ └── console.log │ └── scripts │ │ ├── debian │ │ └── nginx-admin-agent.sh │ │ └── red-hat │ │ └── nginx-admin-agent.sh ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── jslsolucoes │ │ └── nginx │ │ └── admin │ │ └── agent │ │ └── standalone │ │ ├── Main.java │ │ └── mode │ │ ├── Argument.java │ │ └── ArgumentMode.java │ └── resources │ └── keystore.jks ├── nginx-admin-agent ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── jslsolucoes │ │ │ └── nginx │ │ │ └── admin │ │ │ └── agent │ │ │ ├── JaxRsApplication.java │ │ │ ├── auth │ │ │ ├── AuthHandler.java │ │ │ └── AuthHandlerInterceptor.java │ │ │ ├── configuration │ │ │ └── ConfigurationFactory.java │ │ │ ├── error │ │ │ ├── ErrorHandler.java │ │ │ └── ErrorInterceptor.java │ │ │ └── resource │ │ │ ├── NginxAccessLogResource.java │ │ │ ├── NginxAdminResource.java │ │ │ ├── NginxCommandLineInterfaceResource.java │ │ │ ├── NginxErrorLogResource.java │ │ │ ├── NginxImportResource.java │ │ │ ├── NginxIndexResource.java │ │ │ ├── NginxSslResource.java │ │ │ ├── NginxUpstreamResource.java │ │ │ ├── NginxVirtualHostResource.java │ │ │ └── impl │ │ │ ├── NginxAccessLogResourceImpl.java │ │ │ ├── NginxAdminResourceImpl.java │ │ │ ├── NginxCommandLineInterfaceResourceImpl.java │ │ │ ├── NginxErrorLogResourceImpl.java │ │ │ ├── NginxImportResourceImpl.java │ │ │ ├── NginxOperationResult.java │ │ │ ├── NginxOperationResultType.java │ │ │ ├── NginxSslResourceImpl.java │ │ │ ├── NginxUpstreamResourceImpl.java │ │ │ ├── NginxVirtualHostResourceImpl.java │ │ │ ├── info │ │ │ ├── NginxInfo.java │ │ │ └── NginxInfoDiscover.java │ │ │ ├── os │ │ │ ├── OperationalSystem.java │ │ │ ├── OperationalSystemInfo.java │ │ │ └── OperationalSystemType.java │ │ │ └── status │ │ │ ├── NginxStatus.java │ │ │ └── NginxStatusDiscover.java │ ├── resources │ │ ├── META-INF │ │ │ └── beans.xml │ │ └── template │ │ │ └── nginx │ │ │ ├── dynamic │ │ │ ├── nginx.tpl │ │ │ ├── root.tpl │ │ │ ├── upstream.tpl │ │ │ └── virtual-host.tpl │ │ │ └── fixed │ │ │ ├── html │ │ │ ├── 401.html │ │ │ ├── 403.html │ │ │ ├── 404.html │ │ │ ├── 50x.html │ │ │ ├── css │ │ │ │ ├── app.css │ │ │ │ └── bootstrap.css │ │ │ ├── image │ │ │ │ └── logo.png │ │ │ ├── index.html │ │ │ └── js │ │ │ │ ├── bootstrap.js │ │ │ │ └── jquery.js │ │ │ ├── log │ │ │ ├── access.log │ │ │ └── error.log │ │ │ ├── mime.types │ │ │ ├── ssl │ │ │ └── dhparam.pem │ │ │ ├── upstream │ │ │ └── default.conf │ │ │ └── virtual-host │ │ │ └── default.conf │ └── webapp │ │ └── WEB-INF │ │ └── web.xml │ └── test │ └── java │ └── com │ └── jslsolucoes │ └── nginx │ └── admin │ └── agent │ └── resource │ └── impl │ └── NginxVirtualHostResourceImplTest.java ├── nginx-admin-database ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── jslsolucoes │ │ │ └── nginx │ │ │ └── admin │ │ │ └── database │ │ │ ├── DatabaseDriver.java │ │ │ ├── DatabaseMigrationBuilder.java │ │ │ ├── DatabaseMigrationPropertiesBuilder.java │ │ │ ├── DatabaseSqlResource.java │ │ │ ├── model │ │ │ └── DatabaseHistory.java │ │ │ └── repository │ │ │ ├── DatabaseHistoryRepository.java │ │ │ └── impl │ │ │ ├── DatabaseHistoryRepositoryImpl.java │ │ │ └── driver │ │ │ ├── DriverQuery.java │ │ │ ├── GenericDriverQuery.java │ │ │ ├── H2DriverQuery.java │ │ │ ├── MariaDbDriverQuery.java │ │ │ └── MysqlDriverQuery.java │ └── resources │ │ └── db │ │ ├── h2 │ │ ├── create.tpl │ │ ├── current.tpl │ │ ├── exists.tpl │ │ ├── init.tpl │ │ └── insert.tpl │ │ ├── mariadb │ │ ├── create.tpl │ │ ├── current.tpl │ │ ├── exists.tpl │ │ ├── init.tpl │ │ └── insert.tpl │ │ └── mysql │ │ ├── create.tpl │ │ ├── current.tpl │ │ ├── exists.tpl │ │ ├── init.tpl │ │ └── insert.tpl │ └── test │ ├── java │ └── com │ │ └── jslsolucoes │ │ └── nginx │ │ └── admin │ │ └── database │ │ └── DatabaseMigrateTest.java │ └── resources │ ├── db │ └── migration │ │ ├── h2 │ │ ├── v.2.0.0.sql │ │ ├── v.2.0.1.sql │ │ ├── v.2.2.2.sql │ │ └── v.3.sql │ │ └── mysql │ │ ├── v.2.0.0.sql │ │ └── v.2.0.1.sql │ ├── db2 │ ├── v.2.0.0.1.sql │ └── v.2.0.1.2.sql │ └── log4j.properties ├── nginx-admin-docker ├── image │ ├── nginx-admin-agent │ │ ├── debian │ │ │ └── Dockerfile │ │ └── red-hat │ │ │ └── Dockerfile │ └── nginx-admin │ │ ├── debian │ │ └── Dockerfile │ │ └── red-hat │ │ └── Dockerfile ├── qas │ ├── docker-compose.txt │ ├── docker-compose.yml │ ├── docker.txt │ ├── nginx-admin-agent │ │ ├── debian │ │ │ ├── Dockerfile │ │ │ └── build │ │ │ │ └── supervisord.conf │ │ └── red-hat │ │ │ ├── Dockerfile │ │ │ └── build │ │ │ └── supervisord.conf │ └── nginx-admin │ │ ├── debian │ │ ├── Dockerfile │ │ └── build │ │ │ └── supervisord.conf │ │ └── red-hat │ │ ├── Dockerfile │ │ └── build │ │ └── supervisord.conf └── release │ ├── nginx-admin-agent │ ├── debian │ │ └── build │ │ │ └── install.sh │ └── red-hat │ │ └── build │ │ └── install.sh │ └── nginx-admin │ ├── debian │ └── build │ │ └── install.sh │ └── red-hat │ └── build │ └── install.sh ├── nginx-admin-parser ├── pom.xml └── src │ ├── main │ └── java │ │ └── com │ │ └── jslsolucoes │ │ └── nginx │ │ └── admin │ │ └── nginx │ │ └── parser │ │ ├── FileContentReader.java │ │ ├── NginxConfParser.java │ │ ├── Parser.java │ │ ├── ServerParser.java │ │ ├── UpstreamParser.java │ │ └── directive │ │ ├── Directive.java │ │ ├── DirectiveType.java │ │ ├── LocationDirective.java │ │ ├── SslDirective.java │ │ ├── UpstreamDirective.java │ │ ├── UpstreamDirectiveServer.java │ │ └── VirtualHostDirective.java │ └── test │ ├── java │ └── com │ │ └── jslsolucoes │ │ └── nginx │ │ └── admin │ │ └── nginx │ │ └── parser │ │ ├── ServerParserTest.java │ │ └── TestFileLoader.java │ └── resources │ └── data │ └── template │ └── nginx │ └── test_root.conf ├── nginx-admin-ui-configuration ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── jslsolucoes │ └── nginx │ └── admin │ └── ui │ └── config │ ├── Application.java │ ├── Configuration.java │ ├── ConfigurationLoader.java │ ├── Database.java │ ├── DatabasePool.java │ ├── Log.java │ ├── Server.java │ └── Smtp.java ├── nginx-admin-ui-standalone ├── assembly │ └── full.xml ├── nginx-admin │ ├── conf │ │ └── nginx-admin.conf │ ├── log │ │ └── console.log │ └── scripts │ │ ├── debian │ │ └── nginx-admin.sh │ │ └── red-hat │ │ └── nginx-admin.sh ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── jslsolucoes │ │ └── nginx │ │ └── admin │ │ └── ui │ │ └── standalone │ │ ├── Main.java │ │ └── mode │ │ ├── Argument.java │ │ └── ArgumentMode.java │ └── resources │ ├── db │ └── migration │ │ ├── h2 │ │ ├── v.2.0.0.sql │ │ ├── v.2.0.1.sql │ │ ├── v.2.0.2.sql │ │ └── v.2.0.3.sql │ │ ├── mariadb │ │ ├── v.2.0.0.sql │ │ ├── v.2.0.1.sql │ │ ├── v.2.0.2.sql │ │ └── v.2.0.3.sql │ │ ├── mysql │ │ ├── v.2.0.0.sql │ │ ├── v.2.0.1.sql │ │ ├── v.2.0.2.sql │ │ └── v.2.0.3.sql │ │ └── oceanbase │ │ ├── v.2.0.0.sql │ │ ├── v.2.0.1.sql │ │ ├── v.2.0.2.sql │ │ └── v.2.0.3.sql │ ├── keystore.jks │ └── modules │ ├── com │ ├── h2database │ │ └── h2 │ │ │ └── main │ │ │ └── module.xml │ ├── microsoft │ │ └── sqlserver │ │ │ └── main │ │ │ └── module.xml │ ├── mysql │ │ └── main │ │ │ └── module.xml │ └── oracle │ │ └── main │ │ └── module.xml │ └── org │ ├── mariadb │ └── main │ │ └── module.xml │ └── postgresql │ └── main │ └── module.xml ├── nginx-admin-ui ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── jslsolucoes │ │ │ └── nginx │ │ │ └── admin │ │ │ ├── ClientTest.java │ │ │ ├── JaxRsApplication.java │ │ │ ├── agent │ │ │ └── NginxAgentRunner.java │ │ │ ├── controller │ │ │ ├── AccessLogController.java │ │ │ ├── AppController.java │ │ │ ├── ConfigurationController.java │ │ │ ├── DashboardController.java │ │ │ ├── ErrorLogController.java │ │ │ ├── ImportController.java │ │ │ ├── IndexController.java │ │ │ ├── NginxController.java │ │ │ ├── ReportController.java │ │ │ ├── ServerController.java │ │ │ ├── SettingsController.java │ │ │ ├── SslCertificateController.java │ │ │ ├── StrategyController.java │ │ │ ├── UpstreamController.java │ │ │ ├── UserController.java │ │ │ └── VirtualHostController.java │ │ │ ├── error │ │ │ ├── NginxAdminException.java │ │ │ └── NginxAdminRuntimeException.java │ │ │ ├── factory │ │ │ ├── ConfigurationFactory.java │ │ │ └── NginxAgentClientFactory.java │ │ │ ├── jpa │ │ │ └── OverrideEntityManagerConfiguration.java │ │ │ ├── model │ │ │ ├── AccessLog.java │ │ │ ├── Configuration.java │ │ │ ├── ErrorLog.java │ │ │ ├── Nginx.java │ │ │ ├── ResourceIdentifier.java │ │ │ ├── Server.java │ │ │ ├── SslCertificate.java │ │ │ ├── Strategy.java │ │ │ ├── Upstream.java │ │ │ ├── UpstreamServer.java │ │ │ ├── User.java │ │ │ ├── VirtualHost.java │ │ │ ├── VirtualHostAlias.java │ │ │ └── VirtualHostLocation.java │ │ │ ├── repository │ │ │ ├── AccessLogRepository.java │ │ │ ├── ConfigurationRepository.java │ │ │ ├── ErrorLogRepository.java │ │ │ ├── ImportRepository.java │ │ │ ├── NginxRepository.java │ │ │ ├── ReportRepository.java │ │ │ ├── ResourceIdentifierRepository.java │ │ │ ├── ServerRepository.java │ │ │ ├── SslCertificateRepository.java │ │ │ ├── StrategyRepository.java │ │ │ ├── UpstreamRepository.java │ │ │ ├── UpstreamServerRepository.java │ │ │ ├── UserRepository.java │ │ │ ├── VirtualHostAliasRepository.java │ │ │ ├── VirtualHostLocationRepository.java │ │ │ ├── VirtualHostRepository.java │ │ │ └── impl │ │ │ │ ├── AccessLogRepositoryImpl.java │ │ │ │ ├── ConfigurationRepositoryImpl.java │ │ │ │ ├── ErrorLogRepositoryImpl.java │ │ │ │ ├── ImportRepositoryImpl.java │ │ │ │ ├── NginxRepositoryImpl.java │ │ │ │ ├── OperationResult.java │ │ │ │ ├── OperationStatusType.java │ │ │ │ ├── ReportRepositoryImpl.java │ │ │ │ ├── RepositoryImpl.java │ │ │ │ ├── ResourceIdentifierRepositoryImpl.java │ │ │ │ ├── ServerRepositoryImpl.java │ │ │ │ ├── SslCertificateRepositoryImpl.java │ │ │ │ ├── StrategyRepositoryImpl.java │ │ │ │ ├── UpstreamRepositoryImpl.java │ │ │ │ ├── UpstreamServerRepositoryImpl.java │ │ │ │ ├── UserRepositoryImpl.java │ │ │ │ ├── VirtualHostAliasRepositoryImpl.java │ │ │ │ ├── VirtualHostLocationRepositoryImpl.java │ │ │ │ └── VirtualHostRepositoryImpl.java │ │ │ ├── scheduler │ │ │ └── task │ │ │ │ ├── CollectAccessLogTask.java │ │ │ │ ├── CollectErrorLogTask.java │ │ │ │ ├── RotateAccessLogTask.java │ │ │ │ └── RotateErrorLogTask.java │ │ │ └── session │ │ │ └── UserSession.java │ ├── resources │ │ ├── META-INF │ │ │ ├── beans.xml │ │ │ └── persistence.xml │ │ ├── log4j.properties │ │ ├── messages.properties │ │ └── report │ │ │ ├── image │ │ │ └── logo.png │ │ │ ├── statistics.jasper │ │ │ └── statistics.jrxml │ └── webapp │ │ ├── WEB-INF │ │ ├── jsp │ │ │ ├── accessLog │ │ │ │ └── list.jsp │ │ │ ├── app │ │ │ │ ├── edit.jsp │ │ │ │ ├── error.jsp │ │ │ │ ├── forbidden.jsp │ │ │ │ ├── home.jsp │ │ │ │ ├── notFound.jsp │ │ │ │ ├── taglibs.jsp │ │ │ │ └── welcome.jsp │ │ │ ├── configuration │ │ │ │ └── edit.jsp │ │ │ ├── dashboard │ │ │ │ └── index.jsp │ │ │ ├── errorLog │ │ │ │ └── list.jsp │ │ │ ├── import │ │ │ │ └── form.jsp │ │ │ ├── index │ │ │ │ ├── favicon.ico │ │ │ │ └── robots.txt │ │ │ ├── nginx │ │ │ │ ├── form.jsp │ │ │ │ ├── list.jsp │ │ │ │ ├── reload.jsp │ │ │ │ └── tabs.jsp │ │ │ ├── report │ │ │ │ └── search.jsp │ │ │ ├── server │ │ │ │ ├── form.jsp │ │ │ │ └── list.jsp │ │ │ ├── settings │ │ │ │ ├── app.jsp │ │ │ │ ├── home.jsp │ │ │ │ └── smtp.jsp │ │ │ ├── sslCertificate │ │ │ │ ├── form.jsp │ │ │ │ └── list.jsp │ │ │ ├── strategy │ │ │ │ └── data.jsp │ │ │ ├── upstream │ │ │ │ ├── form.jsp │ │ │ │ └── list.jsp │ │ │ ├── user │ │ │ │ ├── changePassword.jsp │ │ │ │ ├── login.jsp │ │ │ │ └── resetPassword.jsp │ │ │ └── virtualHost │ │ │ │ ├── form.jsp │ │ │ │ └── list.jsp │ │ └── web.xml │ │ └── image │ │ └── logo.png │ └── test │ └── java │ └── com │ └── jslsolucoes │ └── nginx │ └── admin │ └── repository │ └── impl │ └── UserRepositoryImplTest.java ├── pom.xml └── settings.xml /.gitignore: -------------------------------------------------------------------------------- 1 | .tern-project 2 | .classpath 3 | .project 4 | .settings 5 | .DS_Store 6 | .factorypath 7 | target 8 | *.war 9 | *.jar 10 | *.zip 11 | *.iml 12 | .idea/*.xml 13 | .idea/libraries/ 14 | .idea/codeStyles/ 15 | .idea/inspectionProfiles/ 16 | opt/ 17 | 18 | -------------------------------------------------------------------------------- /.idea/runConfigurations/Start_nginx_admin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /.idea/runConfigurations/Start_nginx_agent.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.5.4/apache-maven-3.5.4-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | sudo: false 3 | install: true 4 | 5 | addons: 6 | sonarcloud: 7 | organization: "jslsolucoes-github" 8 | branches: 9 | - develop 10 | - master 11 | token: 12 | secure: "15W7WxYtWLtmLVVcFU0z6TLjImKbcYT/PuAW3J5f5ziMW59GejudBeXsnv1WIeXJuslbdkajQcwaxlCcmeScnVNfTR0gscSCKWo+FJIaXfuzHApG3jkzfe+9dtZLUYp76MccSSySn+9xoXREld3FpgvralnBR66irc+5YzoJV9VZyZBfpvZ/VBcK/S6B13z4Iew97IQ+ZIFsXYIXKBrHlvhc96MwNexkzO8hRUDHiFtGf+H50zJfX7GELTnQyIMo56wSIosLWWVxxtFGBFa16sns+RPJbep4a5JufyOFunzMxQo2JMDU524c+RPOhZZGji890wudFML0kxbac/S27qFTqE2D2W/yAxArKVx4gDBP7ujyaz9ZWruncT/VG9narnychzzskfZ+mC+4MpYpI5IGwKeD+8jlXwY7M1b9itnA+XseQ1ocpXkJEa3v1fVtABvtMaHWABXe7ojUG4CYLWKM/+VYO9sVIjSkiIMDhRrIow9DWr6nWfjBno/yYQz7rG1D0OhC5GlzCss7NV4R5klVlqIs7cCehxpn2YXp3ySvH6rmosW2XNwN3+isj0JqNNumriOOQBc9EvYwUrHf1HfdxtHhAuYFejZxLrYy++ySuVJYQszaCDeOfkDeglgTOcWvmFPvt2G2QgTFwhn6FyA1xmARBfPOlx8MXEm9mUs=" 13 | 14 | jdk: 15 | - oraclejdk8 16 | 17 | script: 18 | - mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -DskipTests 19 | 20 | cache: 21 | directories: 22 | - '$HOME/.m2/repository' 23 | - '$HOME/.sonar/cache' 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2019 yizhou.xw 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | /************************************************************* 16 | * Copyright 2018 JSL Solucoes LTDA - https://jslsolucoes.com 17 | * 18 | * Licensed under the Apache License, Version 2.0 (the "License"); 19 | * you may not use this file except in compliance with the License. 20 | * You may obtain a copy of the License at 21 | * 22 | * http://www.apache.org/licenses/LICENSE-2.0 23 | * 24 | * Unless required by applicable law or agreed to in writing, software 25 | * distributed under the License is distributed on an "AS IS" BASIS, 26 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 | * See the License for the specific language governing permissions and 28 | * limitations under the License. 29 | ******************************************************************/ 30 | -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | mvnw.cmd clean install -DskipTests=true -s settings.xml 2 | 3 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | mvnw clean install -DskipTests=true -s settings.xml 3 | 4 | -------------------------------------------------------------------------------- /docs/images/dashboard-page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/docs/images/dashboard-page.png -------------------------------------------------------------------------------- /docs/images/goto-virtual-host-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/docs/images/goto-virtual-host-config.png -------------------------------------------------------------------------------- /docs/images/login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/docs/images/login.png -------------------------------------------------------------------------------- /docs/images/nginx-agent-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/docs/images/nginx-agent-config.png -------------------------------------------------------------------------------- /docs/images/nginx-nodes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/docs/images/nginx-nodes.png -------------------------------------------------------------------------------- /docs/images/select-agent-session.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/docs/images/select-agent-session.png -------------------------------------------------------------------------------- /docs/images/upstream-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/docs/images/upstream-config.png -------------------------------------------------------------------------------- /docs/images/virtual-host-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/docs/images/virtual-host-config.png -------------------------------------------------------------------------------- /docs/install_nginx_admin_guide.md: -------------------------------------------------------------------------------- 1 | # install nginx admin plus 2 | 3 | ## download install script 4 | ``` 5 | cd /tmp 6 | wget -O install-nginx-admin-agent.sh https://raw.githubusercontent.com/alibaba/nginx-admin-plus/master/install/install-nginx-admin-agent.sh 7 | wget -O install-nginx-admin-ui.sh https://raw.githubusercontent.com/alibaba/nginx-admin-plus/master/install/install-nginx-admin-ui.sh 8 | ``` 9 | 10 | ## may need line breaker convert 11 | ``` 12 | dos2unix install-nginx-admin-*.sh 13 | chmod a+x install-nginx-admin-*.sh 14 | ``` 15 | 16 | ## execute install script 17 | ``` 18 | sudo ./install-nginx-admin-agent.sh 19 | sudo ./install-nginx-admin-ui.sh 20 | ``` 21 | -------------------------------------------------------------------------------- /docs/install_nginx_in_centos_6.md: -------------------------------------------------------------------------------- 1 | ## install Nginx in CentOS 6 2 | 3 | > refer from https://www.cyberciti.biz/faq/install-nginx-centos-rhel-6-server-rpm-using-yum-command/ 4 | 5 | ``` 6 | cd /tmp 7 | 8 | wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm 9 | 10 | sudo yum install ./epel-release-latest-*.noarch.rpm 11 | ``` 12 | 13 | ### install nginx 14 | 15 | install nginx rpm repo 16 | ``` 17 | cd /tmp 18 | wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm 19 | rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm 20 | 21 | ``` 22 | 23 | install nginx 24 | ``` 25 | yum install nginx 26 | ``` 27 | 28 | chkconfig 29 | ``` 30 | chkconfig nginx on 31 | ``` 32 | 33 | ### start/run/status 34 | 35 | ``` 36 | service nginx status 37 | service nginx stop 38 | service nginx start 39 | ``` 40 | -------------------------------------------------------------------------------- /docs/nginx_configuration_guide.md: -------------------------------------------------------------------------------- 1 | ## nginx configuration guide 2 | 3 | ### config test 4 | 5 | use `-t` to test config 6 | ``` 7 | sudo nginx -t 8 | ``` 9 | 10 | sample output 11 | ``` 12 | $sudo nginx -t 13 | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 14 | nginx: configuration file /etc/nginx/nginx.conf test is successful 15 | ``` 16 | 17 | ### config reload 18 | 19 | ``` 20 | sudo nginx -s reload 21 | ``` 22 | 23 | ### status check 24 | 25 | > for how to enable stub_status, refer https://www.tecmint.com/enable-nginx-status-page/ 26 | 27 | ``` 28 | server { 29 | listen 80; 30 | server_name __; 31 | location /status { 32 | stub_status on; 33 | allow 127.0.0.1; 34 | deny all; 35 | } 36 | } 37 | ``` 38 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.jslsolucoes 5 | nginx-admin 6 | 2.0.3 7 | 8 | nginx-admin-agent-client 9 | 10 | 11 | 12 | javax 13 | javaee-api 14 | 7.0 15 | provided 16 | 17 | 18 | com.jslsolucoes 19 | nginx-admin-agent-model 20 | ${project.version} 21 | 22 | 23 | junit 24 | junit 25 | 4.12 26 | test 27 | 28 | 29 | org.jboss.resteasy 30 | resteasy-client 31 | 3.1.4.Final 32 | test 33 | 34 | 35 | org.jboss.resteasy 36 | resteasy-jackson-provider 37 | 3.1.4.Final 38 | test 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/java/com/jslsolucoes/nginx/admin/agent/client/NginxAgentClientBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.client; 2 | 3 | import java.util.concurrent.Executors; 4 | import java.util.concurrent.ScheduledExecutorService; 5 | import java.util.concurrent.ThreadFactory; 6 | 7 | public class NginxAgentClientBuilder { 8 | 9 | private final ScheduledExecutorService scheduledExecutorService; 10 | 11 | private NginxAgentClientBuilder() { 12 | this.scheduledExecutorService = Executors.newScheduledThreadPool(1, new ThreadFactory() { 13 | @Override 14 | public Thread newThread(Runnable runnable) { 15 | return new Thread(runnable, "nginx-admin-agent-client"); 16 | } 17 | }); 18 | } 19 | 20 | public static NginxAgentClientBuilder newBuilder() { 21 | return new NginxAgentClientBuilder(); 22 | } 23 | 24 | public NginxAgentClient build() { 25 | return new NginxAgentClient(scheduledExecutorService); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/java/com/jslsolucoes/nginx/admin/agent/client/api/NginxAgentClientApi.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.client.api; 2 | 3 | public interface NginxAgentClientApi { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/java/com/jslsolucoes/nginx/admin/agent/client/api/NginxAgentClientApiBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.client.api; 2 | 3 | public interface NginxAgentClientApiBuilder { 4 | 5 | public NginxAgentClientApi build(); 6 | } 7 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/java/com/jslsolucoes/nginx/admin/agent/client/api/impl/DefaultNginxAgentClientApi.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.client.api.impl; 2 | 3 | import javax.ws.rs.core.Response; 4 | import javax.ws.rs.core.Response.Status; 5 | 6 | import com.jslsolucoes.nginx.admin.agent.client.api.NginxAgentClientApi; 7 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxAuthenticationFailResponse; 8 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxExceptionResponse; 9 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 10 | 11 | public class DefaultNginxAgentClientApi implements NginxAgentClientApi { 12 | 13 | protected NginxResponse responseFor(Response response, Class clazz) { 14 | if (response.getStatusInfo().equals(Status.OK) || response.getStatusInfo().equals(Status.CREATED)) { 15 | return response.readEntity(clazz); 16 | } else if (response.getStatusInfo().equals(Status.FORBIDDEN)) { 17 | return response.readEntity(NginxAuthenticationFailResponse.class); 18 | } else { 19 | return response.readEntity(NginxExceptionResponse.class); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/java/com/jslsolucoes/nginx/admin/agent/client/api/impl/HttpHeader.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.client.api.impl; 2 | 3 | public class HttpHeader { 4 | public final static String AUTHORIZATION = "Authorization"; 5 | } 6 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/java/com/jslsolucoes/nginx/admin/agent/client/api/impl/access/log/NginxAccessLogBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.client.api.impl.access.log; 2 | 3 | import java.util.concurrent.ScheduledExecutorService; 4 | 5 | import com.jslsolucoes.nginx.admin.agent.client.api.NginxAgentClientApiBuilder; 6 | 7 | public class NginxAccessLogBuilder implements NginxAgentClientApiBuilder { 8 | 9 | private ScheduledExecutorService scheduledExecutorService; 10 | private String endpoint; 11 | private String authorizationKey; 12 | 13 | private NginxAccessLogBuilder() { 14 | 15 | } 16 | 17 | @Override 18 | public NginxAccessLog build() { 19 | return new NginxAccessLog(scheduledExecutorService, endpoint, authorizationKey); 20 | } 21 | 22 | public static NginxAccessLogBuilder newBuilder() { 23 | return new NginxAccessLogBuilder(); 24 | } 25 | 26 | public NginxAccessLogBuilder withScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) { 27 | this.scheduledExecutorService = scheduledExecutorService; 28 | return this; 29 | } 30 | 31 | public NginxAccessLogBuilder withEndpoint(String endpoint) { 32 | this.endpoint = endpoint; 33 | return this; 34 | } 35 | 36 | public NginxAccessLogBuilder withAuthorizationKey(String authorizationKey) { 37 | this.authorizationKey = authorizationKey; 38 | return this; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/java/com/jslsolucoes/nginx/admin/agent/client/api/impl/cli/NginxCommandLineInterfaceBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.client.api.impl.cli; 2 | 3 | import java.util.concurrent.ScheduledExecutorService; 4 | 5 | import com.jslsolucoes.nginx.admin.agent.client.api.NginxAgentClientApiBuilder; 6 | 7 | public class NginxCommandLineInterfaceBuilder implements NginxAgentClientApiBuilder { 8 | 9 | private ScheduledExecutorService scheduledExecutorService; 10 | private String endpoint; 11 | private String authorizationKey; 12 | 13 | private NginxCommandLineInterfaceBuilder() { 14 | 15 | } 16 | 17 | @Override 18 | public NginxCommandLineInterface build() { 19 | return new NginxCommandLineInterface(scheduledExecutorService, endpoint, authorizationKey); 20 | } 21 | 22 | public static NginxCommandLineInterfaceBuilder newBuilder() { 23 | return new NginxCommandLineInterfaceBuilder(); 24 | } 25 | 26 | public NginxCommandLineInterfaceBuilder withScheduledExecutorService( 27 | ScheduledExecutorService scheduledExecutorService) { 28 | this.scheduledExecutorService = scheduledExecutorService; 29 | return this; 30 | } 31 | 32 | public NginxCommandLineInterfaceBuilder withEndpoint(String endpoint) { 33 | this.endpoint = endpoint; 34 | return this; 35 | } 36 | 37 | public NginxCommandLineInterfaceBuilder withAuthorizationKey(String authorizationKey) { 38 | this.authorizationKey = authorizationKey; 39 | return this; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/java/com/jslsolucoes/nginx/admin/agent/client/api/impl/error/log/NginxErrorLogBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.client.api.impl.error.log; 2 | 3 | import java.util.concurrent.ScheduledExecutorService; 4 | 5 | import com.jslsolucoes.nginx.admin.agent.client.api.NginxAgentClientApiBuilder; 6 | 7 | public class NginxErrorLogBuilder implements NginxAgentClientApiBuilder { 8 | 9 | private ScheduledExecutorService scheduledExecutorService; 10 | private String endpoint; 11 | private String authorizationKey; 12 | 13 | private NginxErrorLogBuilder() { 14 | 15 | } 16 | 17 | @Override 18 | public NginxErrorLog build() { 19 | return new NginxErrorLog(scheduledExecutorService, endpoint, authorizationKey); 20 | } 21 | 22 | public static NginxErrorLogBuilder newBuilder() { 23 | return new NginxErrorLogBuilder(); 24 | } 25 | 26 | public NginxErrorLogBuilder withScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) { 27 | this.scheduledExecutorService = scheduledExecutorService; 28 | return this; 29 | } 30 | 31 | public NginxErrorLogBuilder withEndpoint(String endpoint) { 32 | this.endpoint = endpoint; 33 | return this; 34 | } 35 | 36 | public NginxErrorLogBuilder withAuthorizationKey(String authorizationKey) { 37 | this.authorizationKey = authorizationKey; 38 | return this; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/java/com/jslsolucoes/nginx/admin/agent/client/api/impl/importation/NginxImportBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.client.api.impl.importation; 2 | 3 | import java.util.concurrent.ScheduledExecutorService; 4 | 5 | import com.jslsolucoes.nginx.admin.agent.client.api.NginxAgentClientApiBuilder; 6 | 7 | public class NginxImportBuilder implements NginxAgentClientApiBuilder { 8 | 9 | private ScheduledExecutorService scheduledExecutorService; 10 | private String endpoint; 11 | private String authorizationKey; 12 | private String conf; 13 | 14 | private NginxImportBuilder() { 15 | 16 | } 17 | 18 | @Override 19 | public NginxImport build() { 20 | return new NginxImport(scheduledExecutorService, endpoint, authorizationKey, conf); 21 | } 22 | 23 | public static NginxImportBuilder newBuilder() { 24 | return new NginxImportBuilder(); 25 | } 26 | 27 | public NginxImportBuilder withScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) { 28 | this.scheduledExecutorService = scheduledExecutorService; 29 | return this; 30 | } 31 | 32 | public NginxImportBuilder withEndpoint(String endpoint) { 33 | this.endpoint = endpoint; 34 | return this; 35 | } 36 | 37 | public NginxImportBuilder withConf(String conf) { 38 | this.conf = conf; 39 | return this; 40 | } 41 | 42 | public NginxImportBuilder withAuthorizationKey(String authorizationKey) { 43 | this.authorizationKey = authorizationKey; 44 | return this; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/java/com/jslsolucoes/nginx/admin/agent/client/api/impl/info/NginxServerInfoBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.client.api.impl.info; 2 | 3 | import java.util.concurrent.ScheduledExecutorService; 4 | 5 | import com.jslsolucoes.nginx.admin.agent.client.api.NginxAgentClientApiBuilder; 6 | 7 | public class NginxServerInfoBuilder implements NginxAgentClientApiBuilder { 8 | 9 | private ScheduledExecutorService scheduledExecutorService; 10 | private String endpoint; 11 | private String authorizationKey; 12 | 13 | private NginxServerInfoBuilder() { 14 | 15 | } 16 | 17 | @Override 18 | public NginxServerInfo build() { 19 | return new NginxServerInfo(scheduledExecutorService, endpoint, authorizationKey); 20 | } 21 | 22 | public static NginxServerInfoBuilder newBuilder() { 23 | return new NginxServerInfoBuilder(); 24 | } 25 | 26 | public NginxServerInfoBuilder withScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) { 27 | this.scheduledExecutorService = scheduledExecutorService; 28 | return this; 29 | } 30 | 31 | public NginxServerInfoBuilder withEndpoint(String endpoint) { 32 | this.endpoint = endpoint; 33 | return this; 34 | } 35 | 36 | public NginxServerInfoBuilder withAuthorizationKey(String authorizationKey) { 37 | this.authorizationKey = authorizationKey; 38 | return this; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/java/com/jslsolucoes/nginx/admin/agent/client/api/impl/os/NginxOperationalSystemInfoBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.client.api.impl.os; 2 | 3 | import java.util.concurrent.ScheduledExecutorService; 4 | 5 | import com.jslsolucoes.nginx.admin.agent.client.api.NginxAgentClientApiBuilder; 6 | import com.jslsolucoes.nginx.admin.agent.client.api.impl.DefaultNginxAgentClientApi; 7 | 8 | public class NginxOperationalSystemInfoBuilder extends DefaultNginxAgentClientApi 9 | implements NginxAgentClientApiBuilder { 10 | 11 | private ScheduledExecutorService scheduledExecutorService; 12 | private String endpoint; 13 | private String authorizationKey; 14 | 15 | private NginxOperationalSystemInfoBuilder() { 16 | 17 | } 18 | 19 | @Override 20 | public NginxOperationalSystemInfo build() { 21 | return new NginxOperationalSystemInfo(scheduledExecutorService, authorizationKey, endpoint); 22 | } 23 | 24 | public static NginxOperationalSystemInfoBuilder newBuilder() { 25 | return new NginxOperationalSystemInfoBuilder(); 26 | } 27 | 28 | public NginxOperationalSystemInfoBuilder withScheduledExecutorService( 29 | ScheduledExecutorService scheduledExecutorService) { 30 | this.scheduledExecutorService = scheduledExecutorService; 31 | return this; 32 | } 33 | 34 | public NginxOperationalSystemInfoBuilder withEndpoint(String endpoint) { 35 | this.endpoint = endpoint; 36 | return this; 37 | } 38 | 39 | public NginxOperationalSystemInfoBuilder withAuthorizationKey(String authorizationKey) { 40 | this.authorizationKey = authorizationKey; 41 | return this; 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/java/com/jslsolucoes/nginx/admin/agent/client/api/impl/ping/NginxPingBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.client.api.impl.ping; 2 | 3 | import java.util.concurrent.ScheduledExecutorService; 4 | 5 | import com.jslsolucoes.nginx.admin.agent.client.api.NginxAgentClientApiBuilder; 6 | 7 | public class NginxPingBuilder implements NginxAgentClientApiBuilder { 8 | 9 | private ScheduledExecutorService scheduledExecutorService; 10 | private String endpoint; 11 | private String authorizationKey; 12 | 13 | private NginxPingBuilder() { 14 | 15 | } 16 | 17 | @Override 18 | public NginxPing build() { 19 | return new NginxPing(scheduledExecutorService, endpoint, authorizationKey); 20 | } 21 | 22 | public static NginxPingBuilder newBuilder() { 23 | return new NginxPingBuilder(); 24 | } 25 | 26 | public NginxPingBuilder withScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) { 27 | this.scheduledExecutorService = scheduledExecutorService; 28 | return this; 29 | } 30 | 31 | public NginxPingBuilder withEndpoint(String endpoint) { 32 | this.endpoint = endpoint; 33 | return this; 34 | } 35 | 36 | public NginxPingBuilder withAuthorizationKey(String authorizationKey) { 37 | this.authorizationKey = authorizationKey; 38 | return this; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/java/com/jslsolucoes/nginx/admin/agent/client/api/impl/status/NginxStatusBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.client.api.impl.status; 2 | 3 | import java.util.concurrent.ScheduledExecutorService; 4 | 5 | import com.jslsolucoes.nginx.admin.agent.client.api.NginxAgentClientApiBuilder; 6 | 7 | public class NginxStatusBuilder implements NginxAgentClientApiBuilder { 8 | 9 | private ScheduledExecutorService scheduledExecutorService; 10 | private String endpoint; 11 | private String authorizationKey; 12 | 13 | private NginxStatusBuilder() { 14 | 15 | } 16 | 17 | @Override 18 | public NginxStatus build() { 19 | return new NginxStatus(scheduledExecutorService, endpoint, authorizationKey); 20 | } 21 | 22 | public static NginxStatusBuilder newBuilder() { 23 | return new NginxStatusBuilder(); 24 | } 25 | 26 | public NginxStatusBuilder withScheduledExecutorService(ScheduledExecutorService scheduledExecutorService) { 27 | this.scheduledExecutorService = scheduledExecutorService; 28 | return this; 29 | } 30 | 31 | public NginxStatusBuilder withEndpoint(String endpoint) { 32 | this.endpoint = endpoint; 33 | return this; 34 | } 35 | 36 | public NginxStatusBuilder withAuthorizationKey(String authorizationKey) { 37 | this.authorizationKey = authorizationKey; 38 | return this; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /nginx-admin-agent-client/src/main/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /nginx-admin-agent-configuration/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | com.jslsolucoes 5 | nginx-admin 6 | 2.0.3 7 | 8 | nginx-admin-agent-configuration 9 | 10 | 11 | 12 | com.jslsolucoes 13 | properties 14 | 1.0.0 15 | 16 | 17 | -------------------------------------------------------------------------------- /nginx-admin-agent-configuration/src/main/java/com/jslsolucoes/nginx/admin/agent/config/Application.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.config; 2 | 3 | public class Application { 4 | 5 | private String version; 6 | private String urlBase; 7 | private String authorizationKey; 8 | private String user; 9 | 10 | public String getVersion() { 11 | return version; 12 | } 13 | 14 | public void setVersion(String version) { 15 | this.version = version; 16 | } 17 | 18 | public String getUrlBase() { 19 | return urlBase; 20 | } 21 | 22 | public void setUrlBase(String urlBase) { 23 | this.urlBase = urlBase; 24 | } 25 | 26 | public String getAuthorizationKey() { 27 | return authorizationKey; 28 | } 29 | 30 | public void setAuthorizationKey(String authorizationKey) { 31 | this.authorizationKey = authorizationKey; 32 | } 33 | 34 | public String getUser() { 35 | return user; 36 | } 37 | 38 | public void setUser(String user) { 39 | this.user = user; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /nginx-admin-agent-configuration/src/main/java/com/jslsolucoes/nginx/admin/agent/config/Configuration.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.config; 2 | 3 | public class Configuration { 4 | 5 | private Server server; 6 | private Application application; 7 | private Nginx nginx; 8 | 9 | public Server getServer() { 10 | return server; 11 | } 12 | 13 | public void setServer(Server server) { 14 | this.server = server; 15 | } 16 | 17 | public Application getApplication() { 18 | return application; 19 | } 20 | 21 | public void setApplication(Application application) { 22 | this.application = application; 23 | } 24 | 25 | public Nginx getNginx() { 26 | return nginx; 27 | } 28 | 29 | public void setNginx(Nginx nginx) { 30 | this.nginx = nginx; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /nginx-admin-agent-configuration/src/main/java/com/jslsolucoes/nginx/admin/agent/config/Nginx.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.config; 2 | 3 | public class Nginx { 4 | 5 | private String bin; 6 | private String setting; 7 | 8 | public String getBin() { 9 | return bin; 10 | } 11 | 12 | public void setBin(String bin) { 13 | this.bin = bin; 14 | } 15 | 16 | public String getSetting() { 17 | return setting; 18 | } 19 | 20 | public void setSetting(String settings) { 21 | this.setting = settings; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /nginx-admin-agent-configuration/src/main/java/com/jslsolucoes/nginx/admin/agent/config/Server.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.config; 2 | 3 | public class Server { 4 | 5 | private Integer httpPort; 6 | private Integer httpsPort; 7 | 8 | public Integer getHttpPort() { 9 | return httpPort; 10 | } 11 | 12 | public void setHttpPort(Integer httpPort) { 13 | this.httpPort = httpPort; 14 | } 15 | 16 | public Integer getHttpsPort() { 17 | return httpsPort; 18 | } 19 | 20 | public void setHttpsPort(Integer httpsPort) { 21 | this.httpsPort = httpsPort; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.jslsolucoes 6 | nginx-admin 7 | 2.0.3 8 | 9 | nginx-admin-agent-model 10 | 11 | 12 | 13 | org.apache.commons 14 | commons-lang3 15 | 3.7 16 | 17 | 18 | com.jslsolucoes 19 | nginx-admin-parser 20 | ${project.version} 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/Endpoint.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model; 2 | 3 | public class Endpoint { 4 | 5 | private String ip; 6 | private Integer port; 7 | 8 | public Endpoint() { 9 | 10 | } 11 | 12 | public Endpoint(String ip, Integer port) { 13 | this.ip = ip; 14 | this.port = port; 15 | } 16 | 17 | public Integer getPort() { 18 | return port; 19 | } 20 | 21 | public void setPort(Integer port) { 22 | this.port = port; 23 | } 24 | 25 | public String getIp() { 26 | return ip; 27 | } 28 | 29 | public void setIp(String ip) { 30 | this.ip = ip; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/FileObject.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.util.Base64; 5 | import java.util.Date; 6 | 7 | public class FileObject { 8 | 9 | private String fileName; 10 | 11 | private Date lastModified; 12 | 13 | private Long size; 14 | 15 | private String content; 16 | 17 | private String charset = "UTF-8"; 18 | 19 | public String getFileName() { 20 | return fileName; 21 | } 22 | 23 | public void setFileName(String fileName) { 24 | this.fileName = fileName; 25 | } 26 | 27 | public Date getLastModified() { 28 | return lastModified; 29 | } 30 | 31 | public void setLastModified(Date lastModified) { 32 | this.lastModified = lastModified; 33 | } 34 | 35 | public Long getSize() { 36 | return size; 37 | } 38 | 39 | public void setSize(Long size) { 40 | this.size = size; 41 | } 42 | 43 | public String getContent() { 44 | try { 45 | return new String(Base64.getDecoder().decode(content.getBytes(charset))); 46 | } catch (UnsupportedEncodingException e) { 47 | throw new RuntimeException(e); 48 | } 49 | } 50 | 51 | public void setContent(String content) { 52 | try { 53 | this.content = Base64.getEncoder().encodeToString(content.getBytes(charset)); 54 | } catch (UnsupportedEncodingException e) { 55 | throw new RuntimeException(e); 56 | } 57 | } 58 | 59 | public String getCharset() { 60 | return charset; 61 | } 62 | 63 | public void setCharset(String charset) { 64 | this.charset = charset; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/FileObjectBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model; 2 | 3 | import java.io.File; 4 | import java.util.Date; 5 | 6 | public class FileObjectBuilder { 7 | 8 | private Date lastModified; 9 | private String name; 10 | private Long size; 11 | private String content; 12 | private String charset = "UTF-8"; 13 | 14 | private FileObjectBuilder() { 15 | 16 | } 17 | 18 | public static FileObjectBuilder newBuilder() { 19 | return new FileObjectBuilder(); 20 | } 21 | 22 | public FileObjectBuilder from(File file) { 23 | this.lastModified = new Date(file.lastModified()); 24 | this.name = file.getName(); 25 | this.size = file.length(); 26 | return this; 27 | } 28 | 29 | public FileObjectBuilder withContent(String content) { 30 | this.content = content; 31 | return this; 32 | } 33 | 34 | public FileObjectBuilder withName(String name) { 35 | this.name = name; 36 | return this; 37 | } 38 | 39 | public FileObjectBuilder withCharset(String charset) { 40 | this.charset = charset; 41 | return this; 42 | } 43 | 44 | public FileObjectBuilder withSize(Long size) { 45 | this.size = size; 46 | return this; 47 | } 48 | 49 | public FileObject build() { 50 | FileObject fileObject = new FileObject(); 51 | fileObject.setLastModified(lastModified); 52 | fileObject.setFileName(name); 53 | fileObject.setSize(size); 54 | fileObject.setCharset(charset); 55 | fileObject.setContent(content); 56 | return fileObject; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/request/NginxConfigureRequest.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.request; 2 | 3 | public class NginxConfigureRequest { 4 | 5 | private Integer maxPostSize; 6 | private Integer rootPort; 7 | private Boolean gzip; 8 | 9 | public NginxConfigureRequest() { 10 | 11 | } 12 | 13 | public NginxConfigureRequest(Integer maxPostSize, Integer rootPort, Boolean gzip) { 14 | this.maxPostSize = maxPostSize; 15 | this.rootPort = rootPort; 16 | this.gzip = gzip; 17 | } 18 | 19 | public Integer getMaxPostSize() { 20 | return maxPostSize; 21 | } 22 | 23 | public void setMaxPostSize(Integer maxPostSize) { 24 | this.maxPostSize = maxPostSize; 25 | } 26 | 27 | public Integer getRootPort() { 28 | return rootPort; 29 | } 30 | 31 | public void setRootPort(Integer rootPort) { 32 | this.rootPort = rootPort; 33 | } 34 | 35 | public Boolean getGzip() { 36 | return gzip; 37 | } 38 | 39 | public void setGzip(Boolean gzip) { 40 | this.gzip = gzip; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/request/NginxImportConfRequest.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.request; 2 | 3 | public class NginxImportConfRequest { 4 | 5 | private String conf; 6 | 7 | public NginxImportConfRequest() { 8 | 9 | } 10 | 11 | public NginxImportConfRequest(String conf) { 12 | this.conf = conf; 13 | } 14 | 15 | public String getConf() { 16 | return conf; 17 | } 18 | 19 | public void setConf(String conf) { 20 | this.conf = conf; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/request/ssl/NginxSslCreateRequest.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.request.ssl; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.FileObject; 4 | 5 | public class NginxSslCreateRequest { 6 | 7 | private FileObject fileObject; 8 | private String uuid; 9 | 10 | public NginxSslCreateRequest() { 11 | 12 | } 13 | 14 | public NginxSslCreateRequest(String uuid, FileObject fileObject) { 15 | this.fileObject = fileObject; 16 | this.uuid = uuid; 17 | } 18 | 19 | public FileObject getFileObject() { 20 | return fileObject; 21 | } 22 | 23 | public void setFileObject(FileObject fileObject) { 24 | this.fileObject = fileObject; 25 | } 26 | 27 | public String getUuid() { 28 | return uuid; 29 | } 30 | 31 | public void setUuid(String uuid) { 32 | this.uuid = uuid; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/request/ssl/NginxSslUpdateRequest.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.request.ssl; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.FileObject; 4 | 5 | public class NginxSslUpdateRequest { 6 | 7 | private FileObject fileObject; 8 | 9 | public NginxSslUpdateRequest() { 10 | 11 | } 12 | 13 | public NginxSslUpdateRequest(FileObject fileObject) { 14 | this.fileObject = fileObject; 15 | } 16 | 17 | public FileObject getFileObject() { 18 | return fileObject; 19 | } 20 | 21 | public void setFileObject(FileObject fileObject) { 22 | this.fileObject = fileObject; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/request/upstream/NginxUpstreamUpdateRequest.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.request.upstream; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.Endpoint; 4 | 5 | import java.util.List; 6 | 7 | public class NginxUpstreamUpdateRequest { 8 | 9 | private String name; 10 | private String additionalLines; 11 | private String strategy; 12 | private List endpoints; 13 | 14 | public NginxUpstreamUpdateRequest() { 15 | 16 | } 17 | 18 | public NginxUpstreamUpdateRequest(String name, String additionalLines, String strategy, List endpoints) { 19 | this.name = name; 20 | this.additionalLines = additionalLines; 21 | this.strategy = strategy; 22 | this.endpoints = endpoints; 23 | } 24 | 25 | public String getName() { 26 | return name; 27 | } 28 | 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | 33 | public String getAdditionalLines() { 34 | return additionalLines; 35 | } 36 | 37 | public void setAdditionalLines(String additionalLines) { 38 | this.additionalLines = additionalLines; 39 | } 40 | 41 | public String getStrategy() { 42 | return strategy; 43 | } 44 | 45 | public void setStrategy(String strategy) { 46 | this.strategy = strategy; 47 | } 48 | 49 | public List getEndpoints() { 50 | return endpoints; 51 | } 52 | 53 | public void setEndpoints(List endpoints) { 54 | this.endpoints = endpoints; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/NginxAuthenticationFailResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response; 2 | 3 | public class NginxAuthenticationFailResponse implements NginxResponse { 4 | 5 | private String message; 6 | 7 | public NginxAuthenticationFailResponse() { 8 | 9 | } 10 | 11 | public NginxAuthenticationFailResponse(String message) { 12 | this.message = message; 13 | } 14 | 15 | public String getMessage() { 16 | return message; 17 | } 18 | 19 | public void setMessage(String message) { 20 | this.message = message; 21 | } 22 | 23 | @Override 24 | public boolean error() { 25 | return false; 26 | } 27 | 28 | @Override 29 | public boolean forbidden() { 30 | return true; 31 | } 32 | 33 | @Override 34 | public boolean success() { 35 | return false; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/NginxCommandLineInterfaceResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response; 2 | 3 | public class NginxCommandLineInterfaceResponse implements NginxResponse { 4 | 5 | private String output; 6 | private Boolean success; 7 | 8 | public NginxCommandLineInterfaceResponse() { 9 | 10 | } 11 | 12 | public NginxCommandLineInterfaceResponse(String output, Boolean success) { 13 | this.output = output; 14 | this.success = success; 15 | } 16 | 17 | public String getOutput() { 18 | return output; 19 | } 20 | 21 | public void setOutput(String output) { 22 | this.output = output; 23 | } 24 | 25 | public Boolean getSuccess() { 26 | return success; 27 | } 28 | 29 | public void setSuccess(Boolean success) { 30 | this.success = success; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/NginxConfigureResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response; 2 | 3 | public class NginxConfigureResponse implements NginxResponse { 4 | 5 | private String stackTrace; 6 | private Boolean success; 7 | 8 | public NginxConfigureResponse() { 9 | 10 | } 11 | 12 | public NginxConfigureResponse(String stackTrace, Boolean success) { 13 | this.stackTrace = stackTrace; 14 | this.success = success; 15 | 16 | } 17 | 18 | public String getStackTrace() { 19 | return stackTrace; 20 | } 21 | 22 | public void setStackTrace(String stackTrace) { 23 | this.stackTrace = stackTrace; 24 | } 25 | 26 | public Boolean getSuccess() { 27 | return success; 28 | } 29 | 30 | public void setSuccess(Boolean success) { 31 | this.success = success; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/NginxExceptionResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response; 2 | 3 | import org.apache.commons.lang3.exception.ExceptionUtils; 4 | 5 | public class NginxExceptionResponse implements NginxResponse { 6 | 7 | private String stackTrace; 8 | 9 | public NginxExceptionResponse() { 10 | 11 | } 12 | 13 | public NginxExceptionResponse(Throwable throwable) { 14 | this.stackTrace = ExceptionUtils.getStackTrace(throwable); 15 | } 16 | 17 | public String getStackTrace() { 18 | return stackTrace; 19 | } 20 | 21 | public void setStackTrace(String stackTrace) { 22 | this.stackTrace = stackTrace; 23 | } 24 | 25 | @Override 26 | public boolean error() { 27 | return true; 28 | } 29 | 30 | @Override 31 | public boolean forbidden() { 32 | return false; 33 | } 34 | 35 | @Override 36 | public boolean success() { 37 | return false; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/NginxImportConfResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response; 2 | 3 | import java.util.List; 4 | 5 | import javax.xml.bind.annotation.XmlElement; 6 | import javax.xml.bind.annotation.XmlElements; 7 | 8 | import com.jslsolucoes.nginx.admin.nginx.parser.directive.Directive; 9 | import com.jslsolucoes.nginx.admin.nginx.parser.directive.LocationDirective; 10 | import com.jslsolucoes.nginx.admin.nginx.parser.directive.UpstreamDirective; 11 | import com.jslsolucoes.nginx.admin.nginx.parser.directive.VirtualHostDirective; 12 | 13 | public class NginxImportConfResponse implements NginxResponse { 14 | 15 | @XmlElements({ @XmlElement(type = VirtualHostDirective.class, name = "virtualHost"), 16 | @XmlElement(type = LocationDirective.class, name = "location"), 17 | @XmlElement(type = UpstreamDirective.class, name = "upstream"), }) 18 | private List directives; 19 | 20 | public NginxImportConfResponse() { 21 | 22 | } 23 | 24 | public NginxImportConfResponse(List directives) { 25 | this.directives = directives; 26 | } 27 | 28 | public List getDirectives() { 29 | return directives; 30 | } 31 | 32 | public void setDirectives(List directives) { 33 | this.directives = directives; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/NginxIndexResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response; 2 | 3 | public class NginxIndexResponse implements NginxResponse { 4 | 5 | private String message; 6 | 7 | public NginxIndexResponse() { 8 | 9 | } 10 | 11 | public NginxIndexResponse(String message) { 12 | this.message = message; 13 | } 14 | 15 | public String getMessage() { 16 | return message; 17 | } 18 | 19 | public void setMessage(String message) { 20 | this.message = message; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/NginxOperationalSystemInfoResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response; 2 | 3 | public class NginxOperationalSystemInfoResponse implements NginxResponse { 4 | 5 | private String architecture; 6 | private String distribution; 7 | private String name; 8 | private String version; 9 | 10 | public NginxOperationalSystemInfoResponse() { 11 | 12 | } 13 | 14 | public NginxOperationalSystemInfoResponse(String architecture, String distribution, String name, String version) { 15 | this.architecture = architecture; 16 | this.distribution = distribution; 17 | this.name = name; 18 | this.version = version; 19 | } 20 | 21 | public String getArchitecture() { 22 | return architecture; 23 | } 24 | 25 | public void setArchitecture(String architecture) { 26 | this.architecture = architecture; 27 | } 28 | 29 | public String getDistribution() { 30 | return distribution; 31 | } 32 | 33 | public void setDistribution(String distribution) { 34 | this.distribution = distribution; 35 | } 36 | 37 | public String getName() { 38 | return name; 39 | } 40 | 41 | public void setName(String name) { 42 | this.name = name; 43 | } 44 | 45 | public String getVersion() { 46 | return version; 47 | } 48 | 49 | public void setVersion(String version) { 50 | this.version = version; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/NginxPingResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response; 2 | 3 | public class NginxPingResponse implements NginxResponse { 4 | 5 | private String message; 6 | 7 | public NginxPingResponse() { 8 | 9 | } 10 | 11 | public NginxPingResponse(String message) { 12 | this.message = message; 13 | } 14 | 15 | public String getMessage() { 16 | return message; 17 | } 18 | 19 | public void setMessage(String message) { 20 | this.message = message; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/NginxResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response; 2 | 3 | public interface NginxResponse { 4 | 5 | default public boolean error() { 6 | return false; 7 | } 8 | 9 | default public boolean forbidden() { 10 | return false; 11 | } 12 | 13 | default public boolean success() { 14 | return true; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/NginxServerInfoResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response; 2 | 3 | import java.math.BigDecimal; 4 | 5 | public class NginxServerInfoResponse implements NginxResponse { 6 | 7 | private String version; 8 | private String address; 9 | private Integer pid; 10 | private BigDecimal uptime; 11 | 12 | public NginxServerInfoResponse() { 13 | 14 | } 15 | 16 | public NginxServerInfoResponse(String version, String address, Integer pid, BigDecimal uptime) { 17 | this.version = version; 18 | this.address = address; 19 | this.pid = pid; 20 | this.uptime = uptime; 21 | } 22 | 23 | public String getVersion() { 24 | return version; 25 | } 26 | 27 | public void setVersion(String version) { 28 | this.version = version; 29 | } 30 | 31 | public String getAddress() { 32 | return address; 33 | } 34 | 35 | public void setAddress(String address) { 36 | this.address = address; 37 | } 38 | 39 | public Integer getPid() { 40 | return pid; 41 | } 42 | 43 | public void setPid(Integer pid) { 44 | this.pid = pid; 45 | } 46 | 47 | public BigDecimal getUptime() { 48 | return uptime; 49 | } 50 | 51 | public void setUptime(BigDecimal uptime) { 52 | this.uptime = uptime; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/access/log/NginxAccessLogCollectResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.access.log; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.agent.model.FileObject; 6 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 7 | 8 | public class NginxAccessLogCollectResponse implements NginxResponse { 9 | 10 | private List files; 11 | 12 | public NginxAccessLogCollectResponse() { 13 | 14 | } 15 | 16 | public NginxAccessLogCollectResponse(List files) { 17 | this.files = files; 18 | } 19 | 20 | public List getFiles() { 21 | return files; 22 | } 23 | 24 | public void setFiles(List files) { 25 | this.files = files; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/access/log/NginxAccessLogRotateResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.access.log; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 4 | 5 | public class NginxAccessLogRotateResponse implements NginxResponse { 6 | 7 | private Integer count; 8 | 9 | public NginxAccessLogRotateResponse() { 10 | 11 | } 12 | 13 | public NginxAccessLogRotateResponse(Integer count) { 14 | this.count = count; 15 | } 16 | 17 | public Integer getCount() { 18 | return count; 19 | } 20 | 21 | public void setCount(Integer count) { 22 | this.count = count; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/error/log/NginxErrorLogCollectResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.error.log; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.agent.model.FileObject; 6 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 7 | 8 | public class NginxErrorLogCollectResponse implements NginxResponse { 9 | 10 | private List files; 11 | 12 | public NginxErrorLogCollectResponse() { 13 | 14 | } 15 | 16 | public NginxErrorLogCollectResponse(List files) { 17 | this.files = files; 18 | } 19 | 20 | public List getFiles() { 21 | return files; 22 | } 23 | 24 | public void setFiles(List files) { 25 | this.files = files; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/error/log/NginxErrorLogRotateResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.error.log; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 4 | 5 | public class NginxErrorLogRotateResponse implements NginxResponse { 6 | 7 | private Integer count; 8 | 9 | public NginxErrorLogRotateResponse() { 10 | 11 | } 12 | 13 | public NginxErrorLogRotateResponse(Integer count) { 14 | this.count = count; 15 | } 16 | 17 | public Integer getCount() { 18 | return count; 19 | } 20 | 21 | public void setCount(Integer count) { 22 | this.count = count; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/ssl/NginxSslCreateResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.ssl; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 4 | 5 | public class NginxSslCreateResponse implements NginxResponse { 6 | 7 | private String stackTrace; 8 | private Boolean success; 9 | 10 | public NginxSslCreateResponse() { 11 | 12 | } 13 | 14 | public NginxSslCreateResponse(String stackTrace, Boolean success) { 15 | this.stackTrace = stackTrace; 16 | this.success = success; 17 | 18 | } 19 | 20 | public String getStackTrace() { 21 | return stackTrace; 22 | } 23 | 24 | public void setStackTrace(String stackTrace) { 25 | this.stackTrace = stackTrace; 26 | } 27 | 28 | public Boolean getSuccess() { 29 | return success; 30 | } 31 | 32 | public void setSuccess(Boolean success) { 33 | this.success = success; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/ssl/NginxSslDeleteResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.ssl; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 4 | 5 | public class NginxSslDeleteResponse implements NginxResponse { 6 | 7 | private String stackTrace; 8 | private Boolean success; 9 | 10 | public NginxSslDeleteResponse() { 11 | 12 | } 13 | 14 | public NginxSslDeleteResponse(String stackTrace, Boolean success) { 15 | this.stackTrace = stackTrace; 16 | this.success = success; 17 | 18 | } 19 | 20 | public String getStackTrace() { 21 | return stackTrace; 22 | } 23 | 24 | public void setStackTrace(String stackTrace) { 25 | this.stackTrace = stackTrace; 26 | } 27 | 28 | public Boolean getSuccess() { 29 | return success; 30 | } 31 | 32 | public void setSuccess(Boolean success) { 33 | this.success = success; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/ssl/NginxSslReadResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.ssl; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.FileObject; 4 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 5 | 6 | public class NginxSslReadResponse implements NginxResponse { 7 | 8 | private FileObject fileObject; 9 | 10 | public NginxSslReadResponse() { 11 | 12 | } 13 | 14 | public NginxSslReadResponse(FileObject fileObject) { 15 | this.fileObject = fileObject; 16 | } 17 | 18 | public FileObject getFileObject() { 19 | return fileObject; 20 | } 21 | 22 | public void setFileObject(FileObject fileObject) { 23 | this.fileObject = fileObject; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/ssl/NginxSslUpdateResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.ssl; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 4 | 5 | public class NginxSslUpdateResponse implements NginxResponse { 6 | 7 | private String stackTrace; 8 | private Boolean success; 9 | 10 | public NginxSslUpdateResponse() { 11 | 12 | } 13 | 14 | public NginxSslUpdateResponse(String stackTrace, Boolean success) { 15 | this.stackTrace = stackTrace; 16 | this.success = success; 17 | 18 | } 19 | 20 | public String getStackTrace() { 21 | return stackTrace; 22 | } 23 | 24 | public void setStackTrace(String stackTrace) { 25 | this.stackTrace = stackTrace; 26 | } 27 | 28 | public Boolean getSuccess() { 29 | return success; 30 | } 31 | 32 | public void setSuccess(Boolean success) { 33 | this.success = success; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/upstream/NginxUpstreamCreateResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.upstream; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 4 | 5 | public class NginxUpstreamCreateResponse implements NginxResponse { 6 | 7 | private String stackTrace; 8 | private Boolean success; 9 | 10 | public NginxUpstreamCreateResponse() { 11 | 12 | } 13 | 14 | public NginxUpstreamCreateResponse(String stackTrace, Boolean success) { 15 | this.stackTrace = stackTrace; 16 | this.success = success; 17 | 18 | } 19 | 20 | public String getStackTrace() { 21 | return stackTrace; 22 | } 23 | 24 | public void setStackTrace(String stackTrace) { 25 | this.stackTrace = stackTrace; 26 | } 27 | 28 | public Boolean getSuccess() { 29 | return success; 30 | } 31 | 32 | public void setSuccess(Boolean success) { 33 | this.success = success; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/upstream/NginxUpstreamDeleteResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.upstream; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 4 | 5 | public class NginxUpstreamDeleteResponse implements NginxResponse { 6 | 7 | private String stackTrace; 8 | private Boolean success; 9 | 10 | public NginxUpstreamDeleteResponse() { 11 | 12 | } 13 | 14 | public NginxUpstreamDeleteResponse(String stackTrace, Boolean success) { 15 | this.stackTrace = stackTrace; 16 | this.success = success; 17 | 18 | } 19 | 20 | public String getStackTrace() { 21 | return stackTrace; 22 | } 23 | 24 | public void setStackTrace(String stackTrace) { 25 | this.stackTrace = stackTrace; 26 | } 27 | 28 | public Boolean getSuccess() { 29 | return success; 30 | } 31 | 32 | public void setSuccess(Boolean success) { 33 | this.success = success; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/upstream/NginxUpstreamReadResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.upstream; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.FileObject; 4 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 5 | 6 | public class NginxUpstreamReadResponse implements NginxResponse { 7 | 8 | private FileObject fileObject; 9 | 10 | public NginxUpstreamReadResponse() { 11 | 12 | } 13 | 14 | public NginxUpstreamReadResponse(FileObject fileObject) { 15 | this.fileObject = fileObject; 16 | } 17 | 18 | public FileObject getFileObject() { 19 | return fileObject; 20 | } 21 | 22 | public void setFileObject(FileObject fileObject) { 23 | this.fileObject = fileObject; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/upstream/NginxUpstreamUpdateResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.upstream; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 4 | 5 | public class NginxUpstreamUpdateResponse implements NginxResponse { 6 | 7 | private String stackTrace; 8 | private Boolean success; 9 | 10 | public NginxUpstreamUpdateResponse() { 11 | 12 | } 13 | 14 | public NginxUpstreamUpdateResponse(String stackTrace, Boolean success) { 15 | this.stackTrace = stackTrace; 16 | this.success = success; 17 | 18 | } 19 | 20 | public String getStackTrace() { 21 | return stackTrace; 22 | } 23 | 24 | public void setStackTrace(String stackTrace) { 25 | this.stackTrace = stackTrace; 26 | } 27 | 28 | public Boolean getSuccess() { 29 | return success; 30 | } 31 | 32 | public void setSuccess(Boolean success) { 33 | this.success = success; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/virtual/host/NginxVirtualHostCreateResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.virtual.host; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 4 | 5 | public class NginxVirtualHostCreateResponse implements NginxResponse { 6 | 7 | private String stackTrace; 8 | private Boolean success; 9 | 10 | public NginxVirtualHostCreateResponse() { 11 | 12 | } 13 | 14 | public NginxVirtualHostCreateResponse(String stackTrace, Boolean success) { 15 | this.stackTrace = stackTrace; 16 | this.success = success; 17 | 18 | } 19 | 20 | public String getStackTrace() { 21 | return stackTrace; 22 | } 23 | 24 | public void setStackTrace(String stackTrace) { 25 | this.stackTrace = stackTrace; 26 | } 27 | 28 | public Boolean getSuccess() { 29 | return success; 30 | } 31 | 32 | public void setSuccess(Boolean success) { 33 | this.success = success; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/virtual/host/NginxVirtualHostDeleteResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.virtual.host; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 4 | 5 | public class NginxVirtualHostDeleteResponse implements NginxResponse { 6 | 7 | private String stackTrace; 8 | private Boolean success; 9 | 10 | public NginxVirtualHostDeleteResponse() { 11 | 12 | } 13 | 14 | public NginxVirtualHostDeleteResponse(String stackTrace, Boolean success) { 15 | this.stackTrace = stackTrace; 16 | this.success = success; 17 | 18 | } 19 | 20 | public String getStackTrace() { 21 | return stackTrace; 22 | } 23 | 24 | public void setStackTrace(String stackTrace) { 25 | this.stackTrace = stackTrace; 26 | } 27 | 28 | public Boolean getSuccess() { 29 | return success; 30 | } 31 | 32 | public void setSuccess(Boolean success) { 33 | this.success = success; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/virtual/host/NginxVirtualHostReadResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.virtual.host; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.FileObject; 4 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 5 | 6 | public class NginxVirtualHostReadResponse implements NginxResponse { 7 | 8 | private FileObject fileObject; 9 | 10 | public NginxVirtualHostReadResponse() { 11 | 12 | } 13 | 14 | public NginxVirtualHostReadResponse(FileObject fileObject) { 15 | this.fileObject = fileObject; 16 | } 17 | 18 | public FileObject getFileObject() { 19 | return fileObject; 20 | } 21 | 22 | public void setFileObject(FileObject fileObject) { 23 | this.fileObject = fileObject; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /nginx-admin-agent-model/src/main/java/com/jslsolucoes/nginx/admin/agent/model/response/virtual/host/NginxVirtualHostUpdateResponse.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.model.response.virtual.host; 2 | 3 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxResponse; 4 | 5 | public class NginxVirtualHostUpdateResponse implements NginxResponse { 6 | 7 | private String stackTrace; 8 | private Boolean success; 9 | 10 | public NginxVirtualHostUpdateResponse() { 11 | 12 | } 13 | 14 | public NginxVirtualHostUpdateResponse(String stackTrace, Boolean success) { 15 | this.stackTrace = stackTrace; 16 | this.success = success; 17 | 18 | } 19 | 20 | public String getStackTrace() { 21 | return stackTrace; 22 | } 23 | 24 | public void setStackTrace(String stackTrace) { 25 | this.stackTrace = stackTrace; 26 | } 27 | 28 | public Boolean getSuccess() { 29 | return success; 30 | } 31 | 32 | public void setSuccess(Boolean success) { 33 | this.success = success; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /nginx-admin-agent-standalone/assembly/full.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | zip 7 | 8 | 9 | 10 | ${project.basedir}/nginx-admin-agent 11 | / 12 | 13 | */** 14 | 15 | 16 | 17 | ${project.build.directory} 18 | /bin 19 | 20 | *-swarm.jar 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /nginx-admin-agent-standalone/nginx-admin-agent/conf/nginx-admin-agent.conf: -------------------------------------------------------------------------------- 1 | JAVA=/usr/bin/java 2 | NGINX_BIN=/usr/sbin/nginx 3 | 4 | NGINX_ADMIN_AGENT_VERSION=2.0.3 5 | NGINX_ADMIN_AGENT_HOME=/opt/nginx-admin-agent-$NGINX_ADMIN_AGENT_VERSION 6 | NGINX_ADMIN_AGENT_BIN=$NGINX_ADMIN_AGENT_HOME/bin 7 | NGINX_ADMIN_AGENT_LOG=$NGINX_ADMIN_AGENT_HOME/log 8 | NGINX_ADMIN_AGENT_CONF=$NGINX_ADMIN_AGENT_HOME/conf 9 | NGINX_ADMIN_AGENT_SETTINGS=$NGINX_ADMIN_AGENT_HOME/settings 10 | NGINX_ADMIN_AGENT_USER=nginx-admin-agent 11 | NGINX_ADMIN_AGENT_HTTP_PORT=3000 12 | NGINX_ADMIN_AGENT_HTTPS_PORT=3443 13 | NGINX_ADMIN_AGENT_AUTHORIZATION_KEY=changeit 14 | 15 | NGINX_ADMIN_AGENT_URL_BASE=http://localhost:3000 16 | 17 | # set 1 to enable remote debug 18 | NGINX_ADMIN_AGENT_REMOTE_DEBUG=0 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /nginx-admin-agent-standalone/nginx-admin-agent/log/console.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/nginx-admin-agent-standalone/nginx-admin-agent/log/console.log -------------------------------------------------------------------------------- /nginx-admin-agent-standalone/src/main/java/com/jslsolucoes/nginx/admin/agent/standalone/mode/Argument.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.standalone.mode; 2 | 3 | public class Argument { 4 | 5 | private String conf; 6 | 7 | private Boolean quit; 8 | 9 | public String getConf() { 10 | return conf; 11 | } 12 | 13 | public void setConf(String conf) { 14 | this.conf = conf; 15 | } 16 | 17 | public Boolean getQuit() { 18 | return quit; 19 | } 20 | 21 | public void setQuit(Boolean quit) { 22 | this.quit = quit; 23 | } 24 | } -------------------------------------------------------------------------------- /nginx-admin-agent-standalone/src/main/resources/keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/nginx-admin-agent-standalone/src/main/resources/keystore.jks -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/java/com/jslsolucoes/nginx/admin/agent/JaxRsApplication.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent; 2 | 3 | import java.util.Arrays; 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | 7 | import javax.ws.rs.ApplicationPath; 8 | import javax.ws.rs.core.Application; 9 | 10 | import com.jslsolucoes.nginx.admin.agent.resource.NginxAccessLogResource; 11 | import com.jslsolucoes.nginx.admin.agent.resource.NginxAdminResource; 12 | import com.jslsolucoes.nginx.admin.agent.resource.NginxCommandLineInterfaceResource; 13 | import com.jslsolucoes.nginx.admin.agent.resource.NginxErrorLogResource; 14 | import com.jslsolucoes.nginx.admin.agent.resource.NginxImportResource; 15 | import com.jslsolucoes.nginx.admin.agent.resource.NginxIndexResource; 16 | import com.jslsolucoes.nginx.admin.agent.resource.NginxSslResource; 17 | import com.jslsolucoes.nginx.admin.agent.resource.NginxUpstreamResource; 18 | import com.jslsolucoes.nginx.admin.agent.resource.NginxVirtualHostResource; 19 | 20 | @ApplicationPath("/") 21 | public class JaxRsApplication extends Application { 22 | @Override 23 | public Set> getClasses() { 24 | return new HashSet>(Arrays.asList(NginxIndexResource.class, NginxCommandLineInterfaceResource.class, 25 | NginxAdminResource.class, NginxAccessLogResource.class, NginxErrorLogResource.class, 26 | NginxSslResource.class, NginxUpstreamResource.class, NginxVirtualHostResource.class, 27 | NginxImportResource.class)); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/java/com/jslsolucoes/nginx/admin/agent/auth/AuthHandler.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.auth; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import javax.interceptor.InterceptorBinding; 9 | 10 | @InterceptorBinding 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target({ ElementType.METHOD, ElementType.TYPE }) 13 | public @interface AuthHandler { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/java/com/jslsolucoes/nginx/admin/agent/configuration/ConfigurationFactory.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.configuration; 2 | 3 | import java.util.Properties; 4 | 5 | import javax.enterprise.context.ApplicationScoped; 6 | import javax.enterprise.inject.Produces; 7 | import javax.inject.Inject; 8 | 9 | import com.jslsolucoes.cdi.misc.annotation.ApplicationProperties; 10 | import com.jslsolucoes.nginx.admin.agent.config.Configuration; 11 | import com.jslsolucoes.nginx.admin.agent.config.ConfigurationLoader; 12 | 13 | @ApplicationScoped 14 | public class ConfigurationFactory { 15 | 16 | @Inject 17 | @ApplicationProperties 18 | private Properties properties; 19 | 20 | @Produces 21 | public Configuration getInstance() { 22 | return ConfigurationLoader.newBuilder().withProperties(properties).build(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/java/com/jslsolucoes/nginx/admin/agent/error/ErrorHandler.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.error; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | import javax.interceptor.InterceptorBinding; 9 | 10 | @InterceptorBinding 11 | @Retention(RetentionPolicy.RUNTIME) 12 | @Target({ ElementType.METHOD, ElementType.TYPE }) 13 | public @interface ErrorHandler { 14 | 15 | } 16 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/java/com/jslsolucoes/nginx/admin/agent/error/ErrorInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.error; 2 | 3 | import javax.annotation.Priority; 4 | import javax.interceptor.AroundInvoke; 5 | import javax.interceptor.Interceptor; 6 | import javax.interceptor.InvocationContext; 7 | import javax.ws.rs.container.AsyncResponse; 8 | import javax.ws.rs.core.Response; 9 | import javax.ws.rs.core.Response.Status; 10 | 11 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxExceptionResponse; 12 | 13 | @Interceptor 14 | @ErrorHandler 15 | @Priority(Interceptor.Priority.APPLICATION) 16 | public class ErrorInterceptor { 17 | 18 | @AroundInvoke 19 | public Object manageError(InvocationContext invocationContext) throws Exception { 20 | try { 21 | return invocationContext.proceed(); 22 | } catch (Exception exception) { 23 | Response response = Response.status(Status.INTERNAL_SERVER_ERROR) 24 | .entity(new NginxExceptionResponse(exception)).build(); 25 | AsyncResponse asyncResponse = asyncResponse(invocationContext); 26 | if (asyncResponse != null) { 27 | asyncResponse.resume(response); 28 | } 29 | return response; 30 | } 31 | } 32 | 33 | private AsyncResponse asyncResponse(InvocationContext invocationContext) { 34 | for (Object object : invocationContext.getParameters()) { 35 | if (AsyncResponse.class.isInstance(object)) { 36 | return (AsyncResponse) object; 37 | } 38 | } 39 | return null; 40 | } 41 | } -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/java/com/jslsolucoes/nginx/admin/agent/resource/NginxIndexResource.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.resource; 2 | 3 | import javax.inject.Inject; 4 | import javax.ws.rs.GET; 5 | import javax.ws.rs.Path; 6 | import javax.ws.rs.Produces; 7 | import javax.ws.rs.core.MediaType; 8 | import javax.ws.rs.core.Response; 9 | 10 | import com.jslsolucoes.nginx.admin.agent.auth.AuthHandler; 11 | import com.jslsolucoes.nginx.admin.agent.config.Configuration; 12 | import com.jslsolucoes.nginx.admin.agent.error.ErrorHandler; 13 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxIndexResponse; 14 | import com.jslsolucoes.nginx.admin.agent.model.response.NginxPingResponse; 15 | 16 | @Path("/") 17 | @ErrorHandler 18 | @AuthHandler 19 | @Produces(MediaType.APPLICATION_JSON) 20 | public class NginxIndexResource { 21 | 22 | private Configuration configuration; 23 | 24 | @Deprecated 25 | public NginxIndexResource() { 26 | 27 | } 28 | 29 | @Inject 30 | public NginxIndexResource(Configuration configuration) { 31 | this.configuration = configuration; 32 | this.configuration = configuration; 33 | } 34 | 35 | @GET 36 | public Response index() { 37 | return Response.ok(new NginxIndexResponse(configuration.getApplication().getVersion())).build(); 38 | } 39 | 40 | @GET 41 | @Path("ping") 42 | public Response ping() { 43 | return Response.ok(new NginxPingResponse("pong")).build(); 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/java/com/jslsolucoes/nginx/admin/agent/resource/impl/NginxImportResourceImpl.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.resource.impl; 2 | 3 | import java.util.List; 4 | 5 | import javax.enterprise.context.RequestScoped; 6 | 7 | import com.jslsolucoes.nginx.admin.nginx.parser.NginxConfParser; 8 | import com.jslsolucoes.nginx.admin.nginx.parser.directive.Directive; 9 | 10 | @RequestScoped 11 | public class NginxImportResourceImpl { 12 | 13 | @Deprecated 14 | public NginxImportResourceImpl() { 15 | 16 | } 17 | 18 | public List importFromConfiguration(String conf) { 19 | return NginxConfParser.newBuilder().withConfigurationFile(conf).parse(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/java/com/jslsolucoes/nginx/admin/agent/resource/impl/NginxOperationResultType.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.resource.impl; 2 | 3 | public enum NginxOperationResultType { 4 | ERROR, SUCCESS 5 | } -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/java/com/jslsolucoes/nginx/admin/agent/resource/impl/info/NginxInfo.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.resource.impl.info; 2 | 3 | import java.math.BigDecimal; 4 | 5 | import javax.enterprise.inject.Vetoed; 6 | 7 | @Vetoed 8 | public class NginxInfo { 9 | 10 | private String version; 11 | private String address; 12 | private Integer pid; 13 | private BigDecimal uptime; 14 | 15 | public String getVersion() { 16 | return version; 17 | } 18 | 19 | public void setVersion(String version) { 20 | this.version = version; 21 | } 22 | 23 | public String getAddress() { 24 | return address; 25 | } 26 | 27 | public void setAddress(String address) { 28 | this.address = address; 29 | } 30 | 31 | public Integer getPid() { 32 | return pid; 33 | } 34 | 35 | public void setPid(Integer pid) { 36 | this.pid = pid; 37 | } 38 | 39 | public BigDecimal getUptime() { 40 | return uptime; 41 | } 42 | 43 | public void setUptime(BigDecimal uptime) { 44 | this.uptime = uptime; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/java/com/jslsolucoes/nginx/admin/agent/resource/impl/os/OperationalSystemInfo.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.resource.impl.os; 2 | 3 | public class OperationalSystemInfo { 4 | private String name; 5 | private String arch; 6 | private String version; 7 | private String distribution; 8 | private OperationalSystemType operationalSystemType; 9 | 10 | public OperationalSystemInfo(String name, String arch, String version) { 11 | this.name = name; 12 | this.arch = arch; 13 | this.version = version; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public String getArch() { 25 | return arch; 26 | } 27 | 28 | public void setArch(String arch) { 29 | this.arch = arch; 30 | } 31 | 32 | public String getVersion() { 33 | return version; 34 | } 35 | 36 | public void setVersion(String version) { 37 | this.version = version; 38 | } 39 | 40 | public OperationalSystemType getOperationalSystemType() { 41 | return operationalSystemType; 42 | } 43 | 44 | public void setOperationalSystemType(OperationalSystemType operationalSystemType) { 45 | this.operationalSystemType = operationalSystemType; 46 | } 47 | 48 | public String getDistribution() { 49 | return distribution; 50 | } 51 | 52 | public void setDistribution(String distribution) { 53 | this.distribution = distribution; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/java/com/jslsolucoes/nginx/admin/agent/resource/impl/os/OperationalSystemType.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.resource.impl.os; 2 | 3 | public enum OperationalSystemType { 4 | WINDOWS, LINUX, MAC, UNKNOW; 5 | } -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/java/com/jslsolucoes/nginx/admin/agent/resource/impl/status/NginxStatus.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.resource.impl.status; 2 | 3 | import javax.enterprise.inject.Vetoed; 4 | 5 | @Vetoed 6 | public class NginxStatus { 7 | 8 | private Integer activeConnection = 0; 9 | private Integer accepts = 0; 10 | private Integer handled = 0; 11 | private Integer requests = 0; 12 | private Integer reading = 0; 13 | private Integer writing = 0; 14 | private Integer waiting = 0; 15 | 16 | public Integer getActiveConnection() { 17 | return activeConnection; 18 | } 19 | 20 | public void setActiveConnection(Integer activeConnection) { 21 | this.activeConnection = activeConnection; 22 | } 23 | 24 | public Integer getAccepts() { 25 | return accepts; 26 | } 27 | 28 | public void setAccepts(Integer accepts) { 29 | this.accepts = accepts; 30 | } 31 | 32 | public Integer getHandled() { 33 | return handled; 34 | } 35 | 36 | public void setHandled(Integer handled) { 37 | this.handled = handled; 38 | } 39 | 40 | public Integer getRequests() { 41 | return requests; 42 | } 43 | 44 | public void setRequests(Integer requests) { 45 | this.requests = requests; 46 | } 47 | 48 | public Integer getReading() { 49 | return reading; 50 | } 51 | 52 | public void setReading(Integer reading) { 53 | this.reading = reading; 54 | } 55 | 56 | public Integer getWriting() { 57 | return writing; 58 | } 59 | 60 | public void setWriting(Integer writing) { 61 | this.writing = writing; 62 | } 63 | 64 | public Integer getWaiting() { 65 | return waiting; 66 | } 67 | 68 | public void setWaiting(Integer waiting) { 69 | this.waiting = waiting; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/dynamic/root.tpl: -------------------------------------------------------------------------------- 1 | server { 2 | listen ${ rootPort?c }; 3 | server_name localhost; 4 | location / { 5 | root ${ settings }/html; 6 | index index.html; 7 | } 8 | 9 | location /status { 10 | stub_status on; 11 | } 12 | 13 | error_page 401 /401.html; 14 | error_page 403 /403.html; 15 | error_page 404 /404.html; 16 | error_page 500 501 502 503 504 /50x.html; 17 | location = /401.html { 18 | root ${ settings }/html; 19 | } 20 | location = /403.html { 21 | root ${ settings }/html; 22 | } 23 | location = /404.html { 24 | root ${ settings }/html; 25 | } 26 | location = /50x.html { 27 | root ${ settings }/html; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/dynamic/upstream.tpl: -------------------------------------------------------------------------------- 1 | upstream ${ name } { 2 | <#if strategy??>${ strategy }; 3 | 4 | <#if additionalLines??>${ additionalLines } 5 | 6 | <#if endpoints??> 7 | <#list endpoints as endpoint> 8 | server ${ endpoint.ip }:${ endpoint.port?c }; 9 | 10 | 11 | } 12 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/fixed/html/401.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Unauthorized! 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | logo 16 |
17 | 18 |
19 |
20 |

Error 401 (Unauthorized)

21 |
22 |
23 |
24 | Sorry, the page that you are looking was not authorized on server 25 |
26 |
27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/fixed/html/403.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Forbidden! 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | logo 16 |
17 | 18 |
19 |
20 |

Error 403 (Forbidden)

21 |
22 |
23 |
24 | Sorry, the page that you are looking is forbidden on server 25 |
26 |
27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/fixed/html/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Page not found! 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | logo 16 |
17 | 18 |
19 |
20 |

Error 404 (Not found)

21 |
22 |
23 |
24 | Sorry, the page that you are looking for was not found on server 25 |
26 |
27 |
28 |
29 | 30 | 31 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/fixed/html/50x.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Error! 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 | logo 16 |
17 | 18 |
19 |
20 |

Error 50x (Server error)

21 |
22 |
23 |
24 | Sorry, the page you are looking for is currently unavailable. If you are the system administrator of this resource then you should check 25 | the errors log for details. 26 |
27 |
28 |
29 |
30 | 31 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/fixed/html/css/app.css: -------------------------------------------------------------------------------- 1 | .block { 2 | margin-top: 20px; 3 | margin-bottom: 20px; 4 | } -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/fixed/html/image/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/nginx-admin-agent/src/main/resources/template/nginx/fixed/html/image/logo.png -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/fixed/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Welcome to nginx! 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 |
16 | logo 17 |
18 | 19 |
20 |
21 |

Welcome to nginx !

22 |
23 |
24 |
25 | Congratulations 26 |
27 |
    28 |
  • If you are seeing this page, the nginx web server is successfully installed and working with nginx admin settings.
  • 29 |
  • Thank you for using nginx and nginx admin plus.
  • 30 |
31 |
32 |
33 |
34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/fixed/log/access.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/nginx-admin-agent/src/main/resources/template/nginx/fixed/log/access.log -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/fixed/log/error.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/nginx-admin-agent/src/main/resources/template/nginx/fixed/log/error.log -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/fixed/ssl/dhparam.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN DH PARAMETERS----- 2 | MIIBCAKCAQEA9NpdX8CjVDSM6mfc7tJgHPCdJ1IVXefnrEcHRGakalst2ezwE/3U 3 | Rtik2PR/Pq4jKMQqogVZe6A3XRr1CSPVAWhRbGz75DT7msW9me2aWVI1kRQGwGsT 4 | c9mtPAilkjv8qDZbamkopkXH7aJlm1q1F+IxsKUCvpJngyYhir5TE32WNM1Y6A5G 5 | XMjLYvPHcmemc364QlRYu2CBEid4s1ZuMc0AQ+SMgvCYfYwTWI7FDJuWjIm/TnXG 6 | q/rt1tw016JvV8abhigPv7XCw7oPCI3N3Xg8SrfKiXeQkU7SXdZqvtA4jelqRpkk 7 | 9RqeyRWCG8W90yN2bStCHryvmmjEs7evgwIBAg== 8 | -----END DH PARAMETERS----- 9 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/fixed/upstream/default.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/nginx-admin-agent/src/main/resources/template/nginx/fixed/upstream/default.conf -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/resources/template/nginx/fixed/virtual-host/default.conf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/nginx-admin-agent/src/main/resources/template/nginx/fixed/virtual-host/default.conf -------------------------------------------------------------------------------- /nginx-admin-agent/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 5 | nginx-admin 6 | 7 | -------------------------------------------------------------------------------- /nginx-admin-agent/src/test/java/com/jslsolucoes/nginx/admin/agent/resource/impl/NginxVirtualHostResourceImplTest.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.agent.resource.impl; 2 | 3 | import com.jslsolucoes.template.TemplateBuilder; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | 7 | import java.io.StringWriter; 8 | 9 | public class NginxVirtualHostResourceImplTest { 10 | 11 | @Test 12 | public void verifyTemplateProcess() { 13 | StringWriter stringWriter = new StringWriter(); 14 | TemplateBuilder.newBuilder() 15 | .withTemplate("${ listenPort?c },${ queueSize?c }") 16 | .withData("listenPort", 1234) 17 | .withData("queueSize", 100000L) 18 | .withOutput(stringWriter) 19 | .process(); 20 | String processed = stringWriter.toString(); 21 | Assert.assertEquals("1234,100000", processed); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /nginx-admin-database/src/main/java/com/jslsolucoes/nginx/admin/database/DatabaseDriver.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.database; 2 | 3 | public enum DatabaseDriver { 4 | ORACLE("oracle"), H2("h2"), MARIADB("mariadb"), MYSQL("mysql"), POSTGRESQL("postgresql"), SQLSERVER("sqlserver"), OCEANBASE( 5 | "oceanbase"); 6 | 7 | private String driverName; 8 | 9 | DatabaseDriver(String driverName) { 10 | this.driverName = driverName; 11 | } 12 | 13 | public String getDriverName() { 14 | return driverName; 15 | } 16 | 17 | public static DatabaseDriver forName(String driverName) { 18 | for (DatabaseDriver databaseDriver : values()) { 19 | if (databaseDriver.getDriverName().equals(driverName)) { 20 | return databaseDriver; 21 | } 22 | } 23 | throw new RuntimeException("Could not select database driver"); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /nginx-admin-database/src/main/java/com/jslsolucoes/nginx/admin/database/DatabaseMigrationPropertiesBuilder.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.database; 2 | 3 | import java.util.Properties; 4 | 5 | public class DatabaseMigrationPropertiesBuilder { 6 | 7 | private DatabaseMigrationBuilder databaseMigrationBuilder; 8 | private Properties properties; 9 | 10 | private DatabaseMigrationPropertiesBuilder(DatabaseMigrationBuilder databaseMigrationBuilder,Properties properties) { 11 | this.databaseMigrationBuilder = databaseMigrationBuilder; 12 | this.properties = properties; 13 | } 14 | 15 | public DatabaseMigrationPropertiesBuilder withProperty(String key,String value){ 16 | this.properties.put(key, value); 17 | return this; 18 | } 19 | 20 | public DatabaseMigrationBuilder end() { 21 | return databaseMigrationBuilder; 22 | } 23 | 24 | public static DatabaseMigrationPropertiesBuilder newBuilder(DatabaseMigrationBuilder databaseMigrationBuilder, 25 | Properties properties) { 26 | return new DatabaseMigrationPropertiesBuilder(databaseMigrationBuilder, properties); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /nginx-admin-database/src/main/java/com/jslsolucoes/nginx/admin/database/DatabaseSqlResource.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.database; 2 | 3 | import java.nio.file.Path; 4 | 5 | public class DatabaseSqlResource { 6 | private Path path; 7 | private Long version; 8 | 9 | public DatabaseSqlResource(Path path, Long version) { 10 | this.path = path; 11 | this.version = version; 12 | } 13 | 14 | public Path getPath() { 15 | return path; 16 | } 17 | 18 | public void setPath(Path path) { 19 | this.path = path; 20 | } 21 | 22 | public Long getVersion() { 23 | return version; 24 | } 25 | 26 | public void setVersion(Long version) { 27 | this.version = version; 28 | } 29 | } -------------------------------------------------------------------------------- /nginx-admin-database/src/main/java/com/jslsolucoes/nginx/admin/database/model/DatabaseHistory.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.database.model; 2 | 3 | public class DatabaseHistory { 4 | 5 | private Long id; 6 | private String name; 7 | private Long version; 8 | 9 | public DatabaseHistory(Long id,String name,Long version) { 10 | this.id = id; 11 | this.name = name; 12 | this.version = version; 13 | } 14 | 15 | public DatabaseHistory(String name,Long version) { 16 | this.name = name; 17 | this.version = version; 18 | } 19 | 20 | public Long getId() { 21 | return id; 22 | } 23 | public void setId(Long id) { 24 | this.id = id; 25 | } 26 | public String getName() { 27 | return name; 28 | } 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | public Long getVersion() { 33 | return version; 34 | } 35 | public void setVersion(Long version) { 36 | this.version = version; 37 | } 38 | 39 | 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /nginx-admin-database/src/main/java/com/jslsolucoes/nginx/admin/database/repository/DatabaseHistoryRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.database.repository; 2 | 3 | import com.jslsolucoes.nginx.admin.database.model.DatabaseHistory; 4 | 5 | public interface DatabaseHistoryRepository { 6 | public Boolean exists(String database,String table); 7 | public void create(String database,String table); 8 | public DatabaseHistory current(String database,String table); 9 | public void insert(String database, String table, String name, Long version); 10 | public void init(String database); 11 | } 12 | -------------------------------------------------------------------------------- /nginx-admin-database/src/main/java/com/jslsolucoes/nginx/admin/database/repository/impl/driver/DriverQuery.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.database.repository.impl.driver; 2 | 3 | public interface DriverQuery { 4 | 5 | public String exists(String database, String table); 6 | 7 | public String create(String database, String table); 8 | 9 | public String current(String database, String table); 10 | 11 | public String insert(String database, String table); 12 | 13 | public String init(String database); 14 | } 15 | -------------------------------------------------------------------------------- /nginx-admin-database/src/main/java/com/jslsolucoes/nginx/admin/database/repository/impl/driver/H2DriverQuery.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.database.repository.impl.driver; 2 | 3 | public class H2DriverQuery extends GenericDriverQuery { 4 | 5 | public H2DriverQuery() { 6 | super("/db/h2"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /nginx-admin-database/src/main/java/com/jslsolucoes/nginx/admin/database/repository/impl/driver/MariaDbDriverQuery.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.database.repository.impl.driver; 2 | 3 | public class MariaDbDriverQuery extends GenericDriverQuery { 4 | 5 | public MariaDbDriverQuery() { 6 | super("/db/mariadb"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /nginx-admin-database/src/main/java/com/jslsolucoes/nginx/admin/database/repository/impl/driver/MysqlDriverQuery.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.database.repository.impl.driver; 2 | 3 | public class MysqlDriverQuery extends GenericDriverQuery { 4 | 5 | public MysqlDriverQuery() { 6 | super("/db/mysql"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/h2/create.tpl: -------------------------------------------------------------------------------- 1 | create schema if not exists ${ database }; 2 | create table ${ database }.${ table } ( 3 | id bigint(10) auto_increment not null, 4 | name varchar(100) not null, 5 | version bigint(12) not null, 6 | primary key (id) 7 | ); 8 | alter table ${ database }.${ table } add constraint ${ table }_uk1 unique(version); -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/h2/current.tpl: -------------------------------------------------------------------------------- 1 | select id,name,version from ${ database }.${ table } order by version desc limit 1; -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/h2/exists.tpl: -------------------------------------------------------------------------------- 1 | SELECT case when count(table_name) > 0 then true else false end as found FROM INFORMATION_SCHEMA.TABLES where table_schema = upper('${ database }') and table_name = upper('${ table }'); -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/h2/init.tpl: -------------------------------------------------------------------------------- 1 | use ${ database }; -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/h2/insert.tpl: -------------------------------------------------------------------------------- 1 | insert into ${ database }.${ table } (name,version) values (?,?); -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/mariadb/create.tpl: -------------------------------------------------------------------------------- 1 | create table ${ database }.${ table } ( 2 | id bigint(10) auto_increment not null, 3 | name varchar(100) not null, 4 | version bigint(12) not null, 5 | primary key (id) 6 | ); 7 | alter table ${ database }.${ table } add constraint ${ table }_uk1 unique(version); -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/mariadb/current.tpl: -------------------------------------------------------------------------------- 1 | select id,name,version from ${ database }.${ table } order by version desc limit 1; -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/mariadb/exists.tpl: -------------------------------------------------------------------------------- 1 | SELECT case when count(table_name) > 0 then true else false end as found FROM INFORMATION_SCHEMA.TABLES where table_schema = '${ database }' and table_name = '${ table }'; -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/mariadb/init.tpl: -------------------------------------------------------------------------------- 1 | use ${ database }; -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/mariadb/insert.tpl: -------------------------------------------------------------------------------- 1 | insert into ${ database }.${ table } (name,version) values (?,?); -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/mysql/create.tpl: -------------------------------------------------------------------------------- 1 | create table ${ database }.${ table } ( 2 | id bigint(10) auto_increment not null, 3 | name varchar(100) not null, 4 | version bigint(12) not null, 5 | primary key (id) 6 | ); 7 | alter table ${ database }.${ table } add constraint ${ table }_uk1 unique(version); -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/mysql/current.tpl: -------------------------------------------------------------------------------- 1 | select id,name,version from ${ database }.${ table } order by version desc limit 1; -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/mysql/exists.tpl: -------------------------------------------------------------------------------- 1 | SELECT case when count(table_name) > 0 then true else false end as found FROM INFORMATION_SCHEMA.TABLES where table_schema = upper('${ database }') and table_name = upper('${ table }'); -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/mysql/init.tpl: -------------------------------------------------------------------------------- 1 | use ${ database }; -------------------------------------------------------------------------------- /nginx-admin-database/src/main/resources/db/mysql/insert.tpl: -------------------------------------------------------------------------------- 1 | insert into ${ database }.${ table } (name,version) values (?,?); -------------------------------------------------------------------------------- /nginx-admin-database/src/test/resources/db/migration/h2/v.2.0.0.sql: -------------------------------------------------------------------------------- 1 | create sequence migrate.user_sq minvalue 1 start with 1 increment by 1; 2 | create table migrate.user ( 3 | id bigint(10) not null, 4 | login varchar(100) not null, 5 | email varchar(100) not null, 6 | password varchar(100) not null, 7 | password_force_change int(1) not null, 8 | primary key (id) 9 | ); 10 | alter table migrate.user add constraint user_uk1 unique(login); 11 | alter table migrate.user add constraint user_uk2 unique(email); 12 | 13 | insert into migrate.user (id,login,email,password,password_force_change) values (migrate.user_sq.nextval,'admin','admin@localhost.com','8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918',1); -------------------------------------------------------------------------------- /nginx-admin-database/src/test/resources/db/migration/h2/v.2.0.1.sql: -------------------------------------------------------------------------------- 1 | select 1 from dual; -------------------------------------------------------------------------------- /nginx-admin-database/src/test/resources/db/migration/h2/v.2.2.2.sql: -------------------------------------------------------------------------------- 1 | select 1 from dual; -------------------------------------------------------------------------------- /nginx-admin-database/src/test/resources/db/migration/h2/v.3.sql: -------------------------------------------------------------------------------- 1 | select 1 from dual; -------------------------------------------------------------------------------- /nginx-admin-database/src/test/resources/db/migration/mysql/v.2.0.0.sql: -------------------------------------------------------------------------------- 1 | create table migrate.user ( 2 | id bigint(10) auto_increment not null, 3 | login varchar(100) not null, 4 | email varchar(100) not null, 5 | password varchar(100) not null, 6 | password_force_change int(1) not null, 7 | primary key (id) 8 | ); 9 | alter table migrate.user add constraint user_uk1 unique(login); 10 | alter table migrate.user add constraint user_uk2 unique(email); 11 | 12 | insert into migrate.user (login,email,password,password_force_change) values ('admin','admin@localhost.com','8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918',1); 13 | -------------------------------------------------------------------------------- /nginx-admin-database/src/test/resources/db/migration/mysql/v.2.0.1.sql: -------------------------------------------------------------------------------- 1 | select 1 from dual; -------------------------------------------------------------------------------- /nginx-admin-database/src/test/resources/db2/v.2.0.0.1.sql: -------------------------------------------------------------------------------- 1 | select 1 from dual; -------------------------------------------------------------------------------- /nginx-admin-database/src/test/resources/db2/v.2.0.1.2.sql: -------------------------------------------------------------------------------- 1 | select 1 from dual; -------------------------------------------------------------------------------- /nginx-admin-database/src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 2 | log4j.appender.stdout.Target=System.out 3 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 4 | log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n 5 | 6 | log4j.rootLogger=warn,stdout 7 | 8 | 9 | log4j.logger.com.jslsolucoes.nginx.admin.database = INFO 10 | 11 | -------------------------------------------------------------------------------- /nginx-admin-docker/image/nginx-admin-agent/debian/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | RUN apt-get -y update 3 | RUN apt-get -y install openjdk-8-jdk unzip sudo nginx python-setuptools wget 4 | RUN easy_install supervisor 5 | RUN printf '[supervisord]\nnodaemon=true\n\n[program:nginx-admin-agent]\ncommand = /opt/nginx-admin-agent-2.0.3/scripts/debian/nginx-admin-agent.sh start\n' >> /etc/supervisord.conf 6 | RUN useradd nginx-admin-agent -r 7 | RUN useradd nginx -r 8 | RUN chmod 640 /etc/sudoers 9 | RUN printf 'nginx-admin-agent ALL=(ALL) NOPASSWD:/usr/sbin/nginx,/usr/bin/pgrep nginx,/usr/bin/killall nginx\nDefaults:nginx-admin-agent !requiretty\n' >> /etc/sudoers 10 | RUN chmod 440 /etc/sudoers 11 | RUN mkdir -p /opt/downloads 12 | RUN wget https://bintray.com/jslsolucoes/nginx-admin/download_file?file_path=nginx-admin-agent-2.0.3.zip -O /opt/downloads/nginx-admin-agent-2.0.3.zip 13 | RUN unzip /opt/downloads/nginx-admin-agent-2.0.3.zip -d /opt 14 | RUN chmod -R 755 /opt/nginx-admin-agent-2.0.3 15 | RUN chown -R nginx-admin-agent:nginx-admin-agent /opt/nginx-admin-agent-2.0.3 16 | ENV NGINX_ADMIN_AGENT_HOME /opt/nginx-admin-agent-2.0.3 17 | EXPOSE 80 18 | EXPOSE 3000 19 | EXPOSE 3443 20 | CMD ["/usr/local/bin/supervisord"] -------------------------------------------------------------------------------- /nginx-admin-docker/image/nginx-admin-agent/red-hat/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | RUN yum -y update 3 | RUN yum -y install epel-release 4 | RUN yum -y install psmisc initscripts java-1.8.0-openjdk-devel.x86_64 nginx unzip sudo python-setuptools wget 5 | RUN easy_install supervisor 6 | RUN printf '[supervisord]\nnodaemon=true\n\n[program:nginx-admin-agent]\ncommand = /opt/nginx-admin-agent-2.0.3/scripts/red-hat/nginx-admin-agent.sh start\n' >> /etc/supervisord.conf 7 | RUN useradd nginx-admin-agent -r 8 | RUN chmod 640 /etc/sudoers 9 | RUN printf 'nginx-admin-agent ALL=(ALL) NOPASSWD:/usr/sbin/nginx,/usr/bin/pgrep nginx,/usr/bin/killall nginx\nDefaults:nginx-admin-agent !requiretty\n' >> /etc/sudoers 10 | RUN chmod 440 /etc/sudoers 11 | RUN mkdir -p /opt/downloads 12 | RUN wget https://bintray.com/jslsolucoes/nginx-admin/download_file?file_path=nginx-admin-agent-2.0.3.zip -O /opt/downloads/nginx-admin-agent-2.0.3.zip 13 | RUN unzip /opt/downloads/nginx-admin-agent-2.0.3.zip -d /opt 14 | RUN chmod -R 755 /opt/nginx-admin-agent-2.0.3 15 | RUN chown -R nginx-admin-agent:nginx-admin-agent /opt/nginx-admin-agent-2.0.3 16 | ENV NGINX_ADMIN_AGENT_HOME /opt/nginx-admin-agent-2.0.3 17 | EXPOSE 80 18 | EXPOSE 3000 19 | EXPOSE 3443 20 | CMD ["/usr/bin/supervisord"] -------------------------------------------------------------------------------- /nginx-admin-docker/image/nginx-admin/debian/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | RUN apt-get -y update 3 | RUN apt-get -y install openjdk-8-jdk unzip python-setuptools wget 4 | RUN easy_install supervisor 5 | RUN printf '[supervisord]\nnodaemon=true\n\n[program:nginx-admin]\ncommand = /opt/nginx-admin-2.0.3/scripts/debian/nginx-admin.sh start\n' >> /etc/supervisord.conf 6 | RUN useradd nginx-admin -r 7 | RUN mkdir -p /opt/downloads 8 | RUN wget https://bintray.com/jslsolucoes/nginx-admin/download_file?file_path=nginx-admin-2.0.3.zip -O /opt/downloads/nginx-admin-2.0.3.zip 9 | RUN unzip /opt/downloads/nginx-admin-2.0.3.zip -d /opt 10 | RUN chmod -R 755 /opt/nginx-admin-2.0.3 11 | RUN chown -R nginx-admin:nginx-admin /opt/nginx-admin-2.0.3 12 | ENV NGINX_ADMIN_HOME /opt/nginx-admin-2.0.3 13 | EXPOSE 4000 14 | EXPOSE 4443 15 | CMD ["/usr/local/bin/supervisord"] -------------------------------------------------------------------------------- /nginx-admin-docker/image/nginx-admin/red-hat/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | RUN yum -y update 3 | RUN yum -y install psmisc initscripts java-1.8.0-openjdk-devel.x86_64 unzip python-setuptools wget 4 | RUN easy_install supervisor 5 | RUN printf '[supervisord]\nnodaemon=true\n\n[program:nginx-admin]\ncommand = /opt/nginx-admin-2.0.3/scripts/red-hat/nginx-admin.sh start\n' >> /etc/supervisord.conf 6 | RUN useradd nginx-admin -r 7 | RUN mkdir -p /opt/downloads 8 | RUN wget https://bintray.com/jslsolucoes/nginx-admin/download_file?file_path=nginx-admin-2.0.3.zip -O /opt/downloads/nginx-admin-2.0.3.zip 9 | RUN unzip /opt/downloads/nginx-admin-2.0.3.zip -d /opt 10 | RUN chmod -R 755 /opt/nginx-admin-2.0.3 11 | RUN chown -R nginx-admin:nginx-admin /opt/nginx-admin-2.0.3 12 | ENV NGINX_ADMIN_HOME /opt/nginx-admin-2.0.3 13 | EXPOSE 4000 14 | EXPOSE 4443 15 | CMD ["/usr/bin/supervisord"] -------------------------------------------------------------------------------- /nginx-admin-docker/qas/docker-compose.txt: -------------------------------------------------------------------------------- 1 | docker-compose build --force-rm 2 | docker-compose up -d --no-build 3 | docker-compose down -------------------------------------------------------------------------------- /nginx-admin-docker/qas/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | nginx-admin-agent-red-hat: 4 | build: nginx-admin-agent/red-hat 5 | image: jslsolucoes/nginx-admin-agent-red-hat:2.0.3 6 | container_name: nginx-admin-agent-red-hat 7 | ports: 8 | - 3000:3000 9 | - 3443:3443 10 | - 3001:80 11 | nginx-admin-agent-debian: 12 | build: nginx-admin-agent/debian 13 | image: jslsolucoes/nginx-admin-agent-debian:2.0.3 14 | container_name: nginx-admin-agent-debian 15 | ports: 16 | - 4000:3000 17 | - 4443:3443 18 | - 4001:80 19 | nginx-admin-red-hat: 20 | build: nginx-admin/red-hat 21 | image: jslsolucoes/nginx-admin-red-hat:2.0.3 22 | container_name: nginx-admin-red-hat 23 | links: 24 | - nginx-admin-agent-red-hat 25 | ports: 26 | - 15000:4000 27 | - 15443:4443 28 | nginx-admin-debian: 29 | build: nginx-admin/debian 30 | image: jslsolucoes/nginx-admin-debian:2.0.3 31 | container_name: nginx-admin-debian 32 | links: 33 | - nginx-admin-agent-debian 34 | ports: 35 | - 16000:4000 36 | - 16443:4443 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /nginx-admin-docker/qas/docker.txt: -------------------------------------------------------------------------------- 1 | # Misc commands 2 | docker rmi $(docker images --quiet --filter "dangling=true") 3 | docker stop $(docker ps -aq) 4 | docker rm $(docker ps -aq) 5 | 6 | #agent 7 | docker build --rm -t nginx-admin-agent-red-hat . 8 | docker run --rm -d -p 3000:3000 -p 3443:3443 -p 3001:80 --name nginx-admin-agent-red-hat jslsolucoes/nginx-admin-agent-red-hat:2.0.3 9 | docker run --rm -it -p 3000:3000 -p 3443:3443 -p 3001:80 jslsolucoes/nginx-admin-agent-red-hat:2.0.3 /bin/bash 10 | 11 | docker build --rm -t nginx-admin-agent-debian . 12 | docker run --rm -d -p 4000:3000 -p 4443:3443 -p 4001:80 --name nginx-admin-agent-debian nginx-admin-agent-debian 13 | docker run --rm -it -p 4000:3000 -p 4443:3443 -p 4001:80 jslsolucoes/nginx-admin-agent-debian:2.0.3 /bin/bash 14 | 15 | #admin 16 | docker build --rm -t nginx-admin-red-hat . 17 | docker run --rm -d --link nginx-admin-agent-red-hat -p 15000:4000 -p 15443:4443 --name nginx-admin-red-hat jslsolucoes/nginx-admin-red-hat:2.0.3 18 | docker run --rm -it --link nginx-admin-agent-red-hat -p 15000:4000 -p 15443:4443 jslsolucoes/nginx-admin-red-hat:2.0.3 /bin/bash 19 | 20 | docker build --rm -t nginx-admin-debian . 21 | docker run --rm -d --link nginx-admin-agent-debian -p 16000:4000 -p 16443:4443 --name nginx-admin-debian nginx-admin-debian 22 | docker run --rm -it --link nginx-admin-agent-debian -p 16000:4000 -p 16443:4443 jslsolucoes/nginx-admin-debian:2.0.3 /bin/bash 23 | -------------------------------------------------------------------------------- /nginx-admin-docker/qas/nginx-admin-agent/debian/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | RUN apt-get -y update 3 | RUN apt-get -y install openjdk-8-jdk unzip sudo nginx python-setuptools 4 | RUN easy_install supervisor 5 | COPY build/supervisord.conf /etc/supervisord.conf 6 | RUN useradd nginx-admin-agent -r 7 | RUN useradd nginx -r 8 | RUN chmod 640 /etc/sudoers 9 | RUN printf 'nginx-admin-agent ALL=(ALL) NOPASSWD:/usr/sbin/nginx,/usr/bin/pgrep nginx,/usr/bin/killall nginx\nDefaults:nginx-admin-agent !requiretty\n' >> /etc/sudoers 10 | RUN chmod 440 /etc/sudoers 11 | RUN mkdir -p /opt/downloads 12 | COPY build/nginx-admin-agent-2.0.3.zip /opt/downloads/nginx-admin-agent-2.0.3.zip 13 | RUN unzip /opt/downloads/nginx-admin-agent-2.0.3.zip -d /opt 14 | RUN chmod -R 755 /opt/nginx-admin-agent-2.0.3 15 | RUN chown -R nginx-admin-agent:nginx-admin-agent /opt/nginx-admin-agent-2.0.3 16 | ENV NGINX_ADMIN_AGENT_HOME /opt/nginx-admin-agent-2.0.3 17 | EXPOSE 80 18 | EXPOSE 3000 19 | EXPOSE 3443 20 | CMD ["/usr/local/bin/supervisord"] -------------------------------------------------------------------------------- /nginx-admin-docker/qas/nginx-admin-agent/debian/build/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:nginx-agent] 5 | command = /opt/nginx-admin-agent-2.0.3/scripts/debian/nginx-admin-agent.sh start -------------------------------------------------------------------------------- /nginx-admin-docker/qas/nginx-admin-agent/red-hat/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | RUN yum -y update 3 | RUN yum -y install epel-release 4 | RUN yum -y install psmisc initscripts java-1.8.0-openjdk-devel.x86_64 nginx unzip sudo python-setuptools 5 | RUN easy_install supervisor 6 | COPY build/supervisord.conf /etc/supervisord.conf 7 | RUN useradd nginx-admin-agent -r 8 | RUN chmod 640 /etc/sudoers 9 | RUN printf 'nginx-admin-agent ALL=(ALL) NOPASSWD:/usr/sbin/nginx,/usr/bin/pgrep nginx,/usr/bin/killall nginx\nDefaults:nginx-admin-agent !requiretty\n' >> /etc/sudoers 10 | RUN chmod 440 /etc/sudoers 11 | RUN mkdir -p /opt/downloads 12 | COPY build/nginx-admin-agent-2.0.3.zip /opt/downloads/nginx-admin-agent-2.0.3.zip 13 | RUN unzip /opt/downloads/nginx-admin-agent-2.0.3.zip -d /opt 14 | RUN chmod -R 755 /opt/nginx-admin-agent-2.0.3 15 | RUN chown -R nginx-admin-agent:nginx-admin-agent /opt/nginx-admin-agent-2.0.3 16 | ENV NGINX_ADMIN_AGENT_HOME /opt/nginx-admin-agent-2.0.3 17 | EXPOSE 80 18 | EXPOSE 3000 19 | EXPOSE 3443 20 | CMD ["/usr/bin/supervisord"] -------------------------------------------------------------------------------- /nginx-admin-docker/qas/nginx-admin-agent/red-hat/build/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:nginx-agent] 5 | command = /opt/nginx-admin-agent-2.0.3/scripts/red-hat/nginx-admin-agent.sh start -------------------------------------------------------------------------------- /nginx-admin-docker/qas/nginx-admin/debian/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | RUN apt-get -y update 3 | RUN apt-get -y install openjdk-8-jdk unzip python-setuptools 4 | RUN easy_install supervisor 5 | COPY build/supervisord.conf /etc/supervisord.conf 6 | RUN useradd nginx-admin -r 7 | RUN mkdir -p /opt/downloads 8 | COPY build/nginx-admin-2.0.3.zip /opt/downloads/nginx-admin-2.0.3.zip 9 | RUN unzip /opt/downloads/nginx-admin-2.0.3.zip -d /opt 10 | RUN chmod -R 755 /opt/nginx-admin-2.0.3 11 | RUN chown -R nginx-admin:nginx-admin /opt/nginx-admin-2.0.3 12 | ENV NGINX_ADMIN_HOME /opt/nginx-admin-2.0.3 13 | EXPOSE 4000 14 | EXPOSE 4443 15 | CMD ["/usr/local/bin/supervisord"] -------------------------------------------------------------------------------- /nginx-admin-docker/qas/nginx-admin/debian/build/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:nginx-admin] 5 | command = /opt/nginx-admin-2.0.3/scripts/debian/nginx-admin.sh start -------------------------------------------------------------------------------- /nginx-admin-docker/qas/nginx-admin/red-hat/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | RUN yum -y update 3 | RUN yum -y install psmisc initscripts java-1.8.0-openjdk-devel.x86_64 unzip python-setuptools 4 | RUN easy_install supervisor 5 | COPY build/supervisord.conf /etc/supervisord.conf 6 | RUN useradd nginx-admin -r 7 | RUN mkdir -p /opt/downloads 8 | COPY build/nginx-admin-2.0.3.zip /opt/downloads/nginx-admin-2.0.3.zip 9 | RUN unzip /opt/downloads/nginx-admin-2.0.3.zip -d /opt 10 | RUN chmod -R 755 /opt/nginx-admin-2.0.3 11 | RUN chown -R nginx-admin:nginx-admin /opt/nginx-admin-2.0.3 12 | ENV NGINX_ADMIN_HOME /opt/nginx-admin-2.0.3 13 | EXPOSE 4000 14 | EXPOSE 4443 15 | CMD ["/usr/bin/supervisord"] -------------------------------------------------------------------------------- /nginx-admin-docker/qas/nginx-admin/red-hat/build/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:nginx-admin] 5 | command = /opt/nginx-admin-2.0.3/scripts/red-hat/nginx-admin.sh start -------------------------------------------------------------------------------- /nginx-admin-docker/release/nginx-admin/debian/build/install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | #check for root 4 | if [ `id -u` -ne 0 ]; then 5 | echo "You need root privileges to run this script" 6 | exit 1 7 | fi 8 | 9 | #install pre-dependencies if has no one 10 | apt-get -y update 11 | apt-get -y install openjdk-8-jdk unzip wget 12 | 13 | #create user for running manager 14 | useradd nginx-admin -r 15 | 16 | #download and extract latest version of nginx manager package 17 | mkdir -p /opt/downloads 18 | wget https://bintray.com/jslsolucoes/nginx-admin/download_file?file_path=nginx-admin-2.0.3.zip -O /opt/downloads/nginx-admin-2.0.3.zip 19 | unzip /opt/downloads/nginx-admin-2.0.3.zip -d /opt 20 | chmod -R 755 /opt/nginx-admin-2.0.3 21 | chown -R nginx-admin:nginx-admin /opt/nginx-admin-2.0.3 22 | 23 | #set environment variable 24 | printf 'NGINX_ADMIN_HOME=/opt/nginx-admin-2.0.3\n' >> /etc/environment 25 | 26 | #add init scripts to os 27 | cp /opt/nginx-admin-2.0.3/scripts/debian/nginx-admin.sh /etc/init.d/nginx-admin 28 | chmod +x /etc/init.d/nginx-admin 29 | chown root:root /etc/init.d/nginx-admin 30 | update-rc.d nginx-admin defaults 31 | update-rc.d nginx-admin enable 32 | 33 | #start service 34 | service nginx-admin start 35 | 36 | #logs from server 37 | tail -f /opt/nginx-admin-2.0.3/log/console.log 38 | 39 | #You can check for manager ui in browser accessing http://localhost:4000 40 | #Please access /opt/nginx-admin-2.0.3/conf/nginx-admin.conf and you can see or change others configurations 41 | #like smtp settings or change database driver connection (NGINX_ADMIN_DB_DRIVER=(h2 or mysql)) if you like in this file and restart service to apply new settings 42 | -------------------------------------------------------------------------------- /nginx-admin-parser/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.jslsolucoes 6 | nginx-admin 7 | 2.0.3 8 | 9 | nginx-admin-parser 10 | 11 | 12 | 13 | commons-io 14 | commons-io 15 | 2.6 16 | 17 | 18 | org.apache.commons 19 | commons-lang3 20 | 3.7 21 | 22 | 23 | org.slf4j 24 | slf4j-api 25 | 1.7.22 26 | 27 | 28 | 29 | junit 30 | junit 31 | 4.12 32 | test 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /nginx-admin-parser/src/main/java/com/jslsolucoes/nginx/admin/nginx/parser/FileContentReader.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.nginx.parser; 2 | 3 | import org.apache.commons.io.FileUtils; 4 | 5 | import java.io.File; 6 | 7 | /** 8 | * @author yizhou.xw 9 | * @date 2019-08-17 10 | **/ 11 | public class FileContentReader { 12 | 13 | /** 14 | * remove comment lines and DOS2UNIX 15 | */ 16 | public static String content(File file) { 17 | try { 18 | return FileUtils.readFileToString(file, "UTF-8") 19 | .replaceAll("\\#(.*)", "") 20 | .replaceAll("\r\n", "\n"); 21 | } catch (Exception e) { 22 | throw new RuntimeException(e); 23 | } 24 | } 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /nginx-admin-parser/src/main/java/com/jslsolucoes/nginx/admin/nginx/parser/Parser.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.nginx.parser; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.nginx.parser.directive.Directive; 6 | 7 | public interface Parser { 8 | public Boolean accepts(); 9 | 10 | public List parse(); 11 | } 12 | -------------------------------------------------------------------------------- /nginx-admin-parser/src/main/java/com/jslsolucoes/nginx/admin/nginx/parser/directive/Directive.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.nginx.parser.directive; 2 | 3 | @FunctionalInterface 4 | public interface Directive { 5 | 6 | public DirectiveType type(); 7 | } 8 | -------------------------------------------------------------------------------- /nginx-admin-parser/src/main/java/com/jslsolucoes/nginx/admin/nginx/parser/directive/DirectiveType.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.nginx.parser.directive; 2 | 3 | public enum DirectiveType { 4 | UPSTREAM, VIRTUAL_HOST 5 | } 6 | -------------------------------------------------------------------------------- /nginx-admin-parser/src/main/java/com/jslsolucoes/nginx/admin/nginx/parser/directive/LocationDirective.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.nginx.parser.directive; 2 | 3 | public class LocationDirective { 4 | 5 | private String path; 6 | private Integer queuePriority; 7 | private String queueHandler; 8 | private String upstream; 9 | 10 | public String getPath() { 11 | return path; 12 | } 13 | 14 | public void setPath(String path) { 15 | this.path = path; 16 | } 17 | 18 | public Integer getQueuePriority() { 19 | return queuePriority; 20 | } 21 | 22 | public void setQueuePriority(Integer queuePriority) { 23 | this.queuePriority = queuePriority; 24 | } 25 | 26 | public String getQueueHandler() { 27 | return queueHandler; 28 | } 29 | 30 | public void setQueueHandler(String queueHandler) { 31 | this.queueHandler = queueHandler; 32 | } 33 | 34 | public String getUpstream() { 35 | return upstream; 36 | } 37 | 38 | public void setUpstream(String upstream) { 39 | this.upstream = upstream; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /nginx-admin-parser/src/main/java/com/jslsolucoes/nginx/admin/nginx/parser/directive/SslDirective.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.nginx.parser.directive; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | import java.util.Base64; 5 | 6 | public class SslDirective { 7 | 8 | private String commonName; 9 | private String content; 10 | private String charset = "UTF-8"; 11 | 12 | public String getCommonName() { 13 | return commonName; 14 | } 15 | 16 | public void setCommonName(String commonName) { 17 | this.commonName = commonName; 18 | } 19 | 20 | public String getContent() { 21 | try { 22 | return new String(Base64.getDecoder().decode(content.getBytes(charset))); 23 | } catch (UnsupportedEncodingException e) { 24 | throw new RuntimeException(e); 25 | } 26 | } 27 | 28 | public void setContent(String value) { 29 | try { 30 | this.content = Base64.getEncoder().encodeToString(value.getBytes(charset)); 31 | } catch (UnsupportedEncodingException e) { 32 | throw new RuntimeException(e); 33 | } 34 | } 35 | 36 | public String getCharset() { 37 | return charset; 38 | } 39 | 40 | public void setCharset(String charset) { 41 | this.charset = charset; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /nginx-admin-parser/src/main/java/com/jslsolucoes/nginx/admin/nginx/parser/directive/UpstreamDirective.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.nginx.parser.directive; 2 | 3 | import java.util.List; 4 | 5 | public class UpstreamDirective implements Directive { 6 | 7 | private String name; 8 | private String strategy; 9 | private List servers; 10 | 11 | public UpstreamDirective() { 12 | 13 | } 14 | 15 | public UpstreamDirective(String name, String strategy, List servers) { 16 | this.name = name; 17 | this.strategy = strategy; 18 | this.servers = servers; 19 | } 20 | 21 | public String getName() { 22 | return name; 23 | } 24 | 25 | public void setName(String name) { 26 | this.name = name; 27 | } 28 | 29 | public String getStrategy() { 30 | return strategy; 31 | } 32 | 33 | public void setStrategy(String strategy) { 34 | this.strategy = strategy; 35 | } 36 | 37 | public List getServers() { 38 | return servers; 39 | } 40 | 41 | public void setServers(List servers) { 42 | this.servers = servers; 43 | } 44 | 45 | @Override 46 | public DirectiveType type() { 47 | return DirectiveType.UPSTREAM; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /nginx-admin-parser/src/main/java/com/jslsolucoes/nginx/admin/nginx/parser/directive/UpstreamDirectiveServer.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.nginx.parser.directive; 2 | 3 | public class UpstreamDirectiveServer { 4 | 5 | private String ip; 6 | private Integer port; 7 | 8 | public String getIp() { 9 | return ip; 10 | } 11 | 12 | public void setIp(String ip) { 13 | this.ip = ip; 14 | } 15 | 16 | public Integer getPort() { 17 | return port; 18 | } 19 | 20 | public void setPort(Integer port) { 21 | this.port = port; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /nginx-admin-parser/src/test/java/com/jslsolucoes/nginx/admin/nginx/parser/ServerParserTest.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.nginx.parser; 2 | 3 | import com.jslsolucoes.nginx.admin.nginx.parser.directive.Directive; 4 | import com.jslsolucoes.nginx.admin.nginx.parser.directive.VirtualHostDirective; 5 | import org.junit.Assert; 6 | import org.junit.Test; 7 | 8 | import java.util.List; 9 | 10 | public class ServerParserTest { 11 | 12 | @Test 13 | public void parse_root_listen_port() { 14 | ServerParser serverParser = new ServerParser(TestFileLoader.content( 15 | "/data/template/nginx/test_root.conf")); 16 | 17 | List directives = serverParser.parse(); 18 | VirtualHostDirective virtualHostDirective = (VirtualHostDirective) directives.stream() 19 | .filter(directive -> directive instanceof VirtualHostDirective) 20 | .findFirst().get(); 21 | 22 | Assert.assertEquals(8080, virtualHostDirective.getPort().intValue()); 23 | } 24 | 25 | @Test 26 | public void accepts_root_expectTrue() { 27 | ServerParser serverParser = new ServerParser(TestFileLoader.content( 28 | "/data/template/nginx/test_root.conf")); 29 | 30 | Boolean accepts = serverParser.accepts(); 31 | 32 | Assert.assertTrue(accepts); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /nginx-admin-parser/src/test/java/com/jslsolucoes/nginx/admin/nginx/parser/TestFileLoader.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.nginx.parser; 2 | 3 | import org.apache.commons.io.IOUtils; 4 | 5 | import java.io.IOException; 6 | 7 | /** 8 | * @author yizhou.xw 9 | * @date 2019-08-17 10 | **/ 11 | public class TestFileLoader { 12 | 13 | public static String content(String path) { 14 | try { 15 | return IOUtils.toString(TestFileLoader.class.getResourceAsStream(path), "UTF-8"); 16 | } catch (IOException ex) { 17 | throw new RuntimeException(ex); 18 | } 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /nginx-admin-parser/src/test/resources/data/template/nginx/test_root.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 8080; 3 | server_name localhost; 4 | location / { 5 | root /opt/nginx/test1/html; 6 | index index.html; 7 | } 8 | 9 | location /status { 10 | stub_status on; 11 | } 12 | 13 | error_page 401 /401.html; 14 | error_page 403 /403.html; 15 | error_page 404 /404.html; 16 | error_page 500 501 502 503 504 /50x.html; 17 | location = /401.html { 18 | root /opt/nginx/test1/html; 19 | } 20 | location = /403.html { 21 | root /opt/nginx/test1/html; 22 | } 23 | location = /404.html { 24 | root /opt/nginx/test1/html; 25 | } 26 | location = /50x.html { 27 | root /opt/nginx/test1/html; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /nginx-admin-ui-configuration/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.jslsolucoes 6 | nginx-admin 7 | 2.0.3 8 | 9 | nginx-admin-ui-configuration 10 | 11 | 12 | 13 | com.jslsolucoes 14 | properties 15 | 1.0.0 16 | 17 | 18 | -------------------------------------------------------------------------------- /nginx-admin-ui-configuration/src/main/java/com/jslsolucoes/nginx/admin/ui/config/Application.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.ui.config; 2 | 3 | public class Application { 4 | private String version; 5 | private String urlBase; 6 | 7 | public String getVersion() { 8 | return version; 9 | } 10 | 11 | public void setVersion(String version) { 12 | this.version = version; 13 | } 14 | 15 | public String getUrlBase() { 16 | return urlBase; 17 | } 18 | 19 | public void setUrlBase(String urlBase) { 20 | this.urlBase = urlBase; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /nginx-admin-ui-configuration/src/main/java/com/jslsolucoes/nginx/admin/ui/config/Configuration.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.ui.config; 2 | 3 | public class Configuration { 4 | 5 | private Log accessLog; 6 | private Log errorLog; 7 | private Server server; 8 | private Database database; 9 | private Application application; 10 | private Smtp smtp; 11 | 12 | public Server getServer() { 13 | return server; 14 | } 15 | 16 | public void setServer(Server server) { 17 | this.server = server; 18 | } 19 | 20 | public Database getDatabase() { 21 | return database; 22 | } 23 | 24 | public void setDatabase(Database database) { 25 | this.database = database; 26 | } 27 | 28 | public Application getApplication() { 29 | return application; 30 | } 31 | 32 | public void setApplication(Application application) { 33 | this.application = application; 34 | } 35 | 36 | public Smtp getSmtp() { 37 | return smtp; 38 | } 39 | 40 | public void setSmtp(Smtp smtp) { 41 | this.smtp = smtp; 42 | } 43 | 44 | public Log getAccessLog() { 45 | return accessLog; 46 | } 47 | 48 | public void setAccessLog(Log accessLog) { 49 | this.accessLog = accessLog; 50 | } 51 | 52 | public Log getErrorLog() { 53 | return errorLog; 54 | } 55 | 56 | public void setErrorLog(Log errorLog) { 57 | this.errorLog = errorLog; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /nginx-admin-ui-configuration/src/main/java/com/jslsolucoes/nginx/admin/ui/config/DatabasePool.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.ui.config; 2 | 3 | public class DatabasePool { 4 | 5 | private Integer maxConnection; 6 | private Integer minConnection; 7 | private Integer initialConnection; 8 | 9 | public Integer getMaxConnection() { 10 | return maxConnection; 11 | } 12 | 13 | public void setMaxConnection(Integer maxConnection) { 14 | this.maxConnection = maxConnection; 15 | } 16 | 17 | public Integer getMinConnection() { 18 | return minConnection; 19 | } 20 | 21 | public void setMinConnection(Integer minConnection) { 22 | this.minConnection = minConnection; 23 | } 24 | 25 | public Integer getInitialConnection() { 26 | return initialConnection; 27 | } 28 | 29 | public void setInitialConnection(Integer initialConnection) { 30 | this.initialConnection = initialConnection; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /nginx-admin-ui-configuration/src/main/java/com/jslsolucoes/nginx/admin/ui/config/Log.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.ui.config; 2 | 3 | public class Log { 4 | 5 | private Integer collect; 6 | private Integer rotate; 7 | 8 | public Integer getCollect() { 9 | return collect; 10 | } 11 | 12 | public void setCollect(Integer collect) { 13 | this.collect = collect; 14 | } 15 | 16 | public Integer getRotate() { 17 | return rotate; 18 | } 19 | 20 | public void setRotate(Integer rotate) { 21 | this.rotate = rotate; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /nginx-admin-ui-configuration/src/main/java/com/jslsolucoes/nginx/admin/ui/config/Server.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.ui.config; 2 | 3 | public class Server { 4 | 5 | private Integer httpPort; 6 | private Integer httpsPort; 7 | 8 | public Integer getHttpPort() { 9 | return httpPort; 10 | } 11 | 12 | public void setHttpPort(Integer httpPort) { 13 | this.httpPort = httpPort; 14 | } 15 | 16 | public Integer getHttpsPort() { 17 | return httpsPort; 18 | } 19 | 20 | public void setHttpsPort(Integer httpsPort) { 21 | this.httpsPort = httpsPort; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/assembly/full.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | zip 7 | 8 | 9 | 10 | ${project.basedir}/nginx-admin 11 | / 12 | 13 | */** 14 | 15 | 16 | 17 | ${project.build.directory} 18 | /bin 19 | 20 | *-swarm.jar 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/nginx-admin/conf/nginx-admin.conf: -------------------------------------------------------------------------------- 1 | JAVA=/usr/bin/java 2 | 3 | NGINX_ADMIN_VERSION=2.0.3 4 | NGINX_ADMIN_HOME=/opt/nginx-admin-$NGINX_ADMIN_VERSION 5 | NGINX_ADMIN_BIN=$NGINX_ADMIN_HOME/bin 6 | NGINX_ADMIN_LOG=$NGINX_ADMIN_HOME/log 7 | NGINX_ADMIN_CONF=$NGINX_ADMIN_HOME/conf 8 | NGINX_ADMIN_USER=nginx-admin 9 | NGINX_ADMIN_HTTP_PORT=4000 10 | NGINX_ADMIN_HTTPS_PORT=4443 11 | NGINX_ADMIN_URL_BASE=http://localhost:4000 12 | 13 | NGINX_ADMIN_LOG_ACCESS_COLLECT_INTERVAL=30 14 | NGINX_ADMIN_LOG_ACCESS_ROTATE_INTERVAL=25 15 | NGINX_ADMIN_LOG_ERROR_COLLECT_INTERVAL=30 16 | NGINX_ADMIN_LOG_ERROR_ROTATE_INTERVAL=25 17 | 18 | NGINX_ADMIN_DB_DRIVER=h2 19 | NGINX_ADMIN_DB_LOCATION=$NGINX_ADMIN_HOME/database 20 | NGINX_ADMIN_DB_HOST=localhost 21 | NGINX_ADMIN_DB_PORT=9123 22 | NGINX_ADMIN_DB_NAME=nginx_admin 23 | NGINX_ADMIN_DB_USERNAME=nginx_admin 24 | NGINX_ADMIN_DB_PASSWORD=changeit 25 | NGINX_ADMIN_DB_POOL_INITIAL=1 26 | NGINX_ADMIN_DB_POOL_MIN=1 27 | NGINX_ADMIN_DB_POOL_MAX=2 28 | 29 | NGINX_ADMIN_MAIL_SERVER=localhost 30 | NGINX_ADMIN_MAIL_PORT=25 31 | NGINX_ADMIN_MAIL_TLS=false 32 | NGINX_ADMIN_MAIL_FROM_NAME=from@localhost.com 33 | NGINX_ADMIN_MAIL_FROM_ADDRESS=from@localhost.com 34 | NGINX_ADMIN_MAIL_AUTHENTICATE=false 35 | NGINX_ADMIN_MAIL_USERNAME=xxxx 36 | NGINX_ADMIN_MAIL_PASSWORD=xxxx 37 | NGINX_ADMIN_MAIL_CHARSET=utf-8 38 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/nginx-admin/log/console.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/nginx-admin-ui-standalone/nginx-admin/log/console.log -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/java/com/jslsolucoes/nginx/admin/ui/standalone/mode/Argument.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.ui.standalone.mode; 2 | 3 | public class Argument { 4 | 5 | private String conf; 6 | 7 | private Boolean quit; 8 | 9 | public String getConf() { 10 | return conf; 11 | } 12 | 13 | public void setConf(String conf) { 14 | this.conf = conf; 15 | } 16 | 17 | public Boolean getQuit() { 18 | return quit; 19 | } 20 | 21 | public void setQuit(Boolean quit) { 22 | this.quit = quit; 23 | } 24 | } -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/java/com/jslsolucoes/nginx/admin/ui/standalone/mode/ArgumentMode.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.ui.standalone.mode; 2 | 3 | import org.apache.commons.cli.CommandLine; 4 | import org.apache.commons.cli.CommandLineParser; 5 | import org.apache.commons.cli.DefaultParser; 6 | import org.apache.commons.cli.HelpFormatter; 7 | import org.apache.commons.cli.Option; 8 | import org.apache.commons.cli.Options; 9 | import org.apache.commons.cli.ParseException; 10 | 11 | public class ArgumentMode { 12 | 13 | private String[] args; 14 | 15 | public ArgumentMode(String[] args) { 16 | this.args = args; 17 | } 18 | 19 | public Argument parse() throws ParseException { 20 | Options options = new Options(); 21 | options.addOption(new Option("help", false, "Help")); 22 | options.addOption(new Option("c", true, "Conf file location")); 23 | 24 | CommandLineParser commandLineParser = new DefaultParser(); 25 | CommandLine commandLine = commandLineParser.parse(options, args); 26 | 27 | Argument argument = new Argument(); 28 | argument.setQuit(false); 29 | 30 | if (commandLine.hasOption("help")) { 31 | HelpFormatter helpFormatter = new HelpFormatter(); 32 | helpFormatter.printHelp("java -jar **.jar", options); 33 | argument.setQuit(true); 34 | } 35 | 36 | for (Option option : options.getOptions()) { 37 | if (option.hasArg() && commandLine.getOptionValue(option.getOpt()) == null) { 38 | System.out 39 | .println("Argument -" + option.getOpt() + " is required to launch. Use -help to see arguments"); 40 | argument.setQuit(true); 41 | } 42 | } 43 | 44 | if (!argument.getQuit()) { 45 | argument.setConf(commandLine.getOptionValue("c")); 46 | } 47 | 48 | return argument; 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/db/migration/h2/v.2.0.1.sql: -------------------------------------------------------------------------------- 1 | alter table strategy add description_key varchar(100) not null default 'strategy.default'; 2 | alter table strategy add directive varchar(100); 3 | 4 | update strategy set directive='ip_hash',name='Ip Hashing',description_key = 'strategy.ip.hashing.description' where name = 'ip_hash'; 5 | update strategy set directive=null,name='Round Robin',description_key = 'strategy.round.robin.description' where name = 'round-robin'; 6 | update strategy set directive='least_conn',name='Least Connected',description_key = 'strategy.least.connected.description' where name = 'least-connected'; 7 | 8 | alter table strategy add constraint strategy_uk2 unique(directive); 9 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/db/migration/h2/v.2.0.2.sql: -------------------------------------------------------------------------------- 1 | alter table virtual_host_location add queue_priority INT(10) not null default 0; 2 | alter table virtual_host_location add queue_handler VARCHAR(64) not null default 'ob.delivery'; 3 | 4 | alter table virtual_host add queue_size BIGINT(10) not null default 10; 5 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/db/migration/h2/v.2.0.3.sql: -------------------------------------------------------------------------------- 1 | alter table nginx add service_name VARCHAR(64) not null default 'nginx'; 2 | alter table nginx add settings_path VARCHAR(256) not null default '/opt/nginx-admin-agent-2.0.3/settings/'; 3 | alter table nginx drop INDEX nginx_uk2; 4 | alter table nginx add constraint nginx_uk_3 unique(endpoint, settings_path); 5 | alter table nginx add constraint nginx_uk_4 unique(endpoint, service_name); 6 | 7 | alter table virtual_host add listen_port INT(5) not null default 8080; 8 | alter table configuration add root_port INT(5) not null default 80; 9 | 10 | alter table upstream add additional_lines VARCHAR(1024) null default null; 11 | 12 | alter table virtual_host_location add additional_lines VARCHAR(1024) null default null; 13 | alter table virtual_host_location modify id_upstream bigint(10) null default null; 14 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/db/migration/mariadb/v.2.0.1.sql: -------------------------------------------------------------------------------- 1 | alter table strategy add description_key varchar(100) not null default 'strategy.default'; 2 | alter table strategy add directive varchar(100); 3 | 4 | update strategy set directive='ip_hash',name='Ip Hashing',description_key = 'strategy.ip.hashing.description' where name = 'ip_hash'; 5 | update strategy set directive=null,name='Round Robin',description_key = 'strategy.round.robin.description' where name = 'round-robin'; 6 | update strategy set directive='least_conn',name='Least Connected',description_key = 'strategy.least.connected.description' where name = 'least-connected'; 7 | 8 | alter table strategy add constraint strategy_uk2 unique(directive); 9 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/db/migration/mariadb/v.2.0.2.sql: -------------------------------------------------------------------------------- 1 | alter table virtual_host_location add queue_priority INT(10) not null default 0; 2 | alter table virtual_host_location add queue_handler VARCHAR(64) not null default 'ob.delivery'; 3 | 4 | alter table virtual_host add queue_size BIGINT(10) not null default 10; 5 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/db/migration/mariadb/v.2.0.3.sql: -------------------------------------------------------------------------------- 1 | alter table nginx add service_name VARCHAR(64) not null default 'nginx'; 2 | alter table nginx add settings_path VARCHAR(256) not null default '/opt/nginx-admin-agent-2.0.3/settings/'; 3 | alter table nginx drop INDEX nginx_uk2; 4 | alter table nginx add constraint nginx_uk_3 unique(endpoint, settings_path); 5 | alter table nginx add constraint nginx_uk_4 unique(endpoint, service_name); 6 | 7 | alter table virtual_host add listen_port INT(5) not null default 8080; 8 | alter table configuration add root_port INT(5) not null default 80; 9 | 10 | alter table upstream add additional_lines VARCHAR(1024) null default null; 11 | 12 | alter table virtual_host_location add additional_lines VARCHAR(1024) null default null; 13 | alter table virtual_host_location modify id_upstream bigint(10) null default null; 14 | 15 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/db/migration/mysql/v.2.0.1.sql: -------------------------------------------------------------------------------- 1 | alter table strategy add description_key varchar(100) not null default 'strategy.default'; 2 | alter table strategy add directive varchar(100); 3 | 4 | update strategy set directive='ip_hash',name='Ip Hashing',description_key = 'strategy.ip.hashing.description' where name = 'ip_hash'; 5 | update strategy set directive=null,name='Round Robin',description_key = 'strategy.round.robin.description' where name = 'round-robin'; 6 | update strategy set directive='least_conn',name='Least Connected',description_key = 'strategy.least.connected.description' where name = 'least-connected'; 7 | 8 | alter table strategy add constraint strategy_uk2 unique(directive); 9 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/db/migration/mysql/v.2.0.2.sql: -------------------------------------------------------------------------------- 1 | alter table virtual_host_location add queue_priority INT(10) not null default 0; 2 | alter table virtual_host_location add queue_handler VARCHAR(64) not null default 'ob.delivery'; 3 | 4 | alter table virtual_host add queue_size BIGINT(10) not null default 10; 5 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/db/migration/mysql/v.2.0.3.sql: -------------------------------------------------------------------------------- 1 | alter table nginx add service_name VARCHAR(64) not null default 'nginx'; 2 | alter table nginx add settings_path VARCHAR(256) not null default '/opt/nginx-admin-agent-2.0.3/settings/'; 3 | alter table nginx drop INDEX nginx_uk2; 4 | alter table nginx add constraint nginx_uk_3 unique(endpoint, settings_path); 5 | alter table nginx add constraint nginx_uk_4 unique(endpoint, service_name); 6 | 7 | alter table virtual_host add listen_port INT(5) not null default 8080; 8 | alter table configuration add root_port INT(5) not null default 80; 9 | 10 | alter table upstream add additional_lines VARCHAR(1024) null default null; 11 | 12 | alter table virtual_host_location add additional_lines VARCHAR(1024) null default null; 13 | alter table virtual_host_location modify id_upstream bigint(10) null default null; 14 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/db/migration/oceanbase/v.2.0.1.sql: -------------------------------------------------------------------------------- 1 | alter table strategy add description_key varchar(100) not null default 'strategy.default'; 2 | alter table strategy add directive varchar(100); 3 | 4 | update strategy set directive='ip_hash',name='Ip Hashing',description_key = 'strategy.ip.hashing.description' where name = 'ip_hash'; 5 | update strategy set directive=null,name='Round Robin',description_key = 'strategy.round.robin.description' where name = 'round-robin'; 6 | update strategy set directive='least_conn',name='Least Connected',description_key = 'strategy.least.connected.description' where name = 'least-connected'; 7 | 8 | alter table strategy add constraint strategy_uk2 unique(directive); 9 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/db/migration/oceanbase/v.2.0.2.sql: -------------------------------------------------------------------------------- 1 | alter table virtual_host_location add queue_priority INT(10) not null default 0; 2 | alter table virtual_host_location add queue_handler VARCHAR(64) not null default 'ob.delivery'; 3 | 4 | alter table virtual_host add queue_size BIGINT(10) not null default 10; 5 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/db/migration/oceanbase/v.2.0.3.sql: -------------------------------------------------------------------------------- 1 | alter table nginx add service_name VARCHAR(64) not null default 'nginx'; 2 | alter table nginx add settings_path VARCHAR(256) not null default '/opt/nginx-admin-agent-2.0.3/settings/'; 3 | alter table nginx drop INDEX nginx_uk2; 4 | alter table nginx add constraint nginx_uk_3 unique(endpoint, settings_path); 5 | alter table nginx add constraint nginx_uk_4 unique(endpoint, service_name); 6 | 7 | alter table virtual_host add listen_port INT(5) not null default 8080; 8 | alter table configuration add root_port INT(5) not null default 80; 9 | 10 | alter table upstream add additional_lines VARCHAR(1024) null default null; 11 | 12 | alter table virtual_host_location add additional_lines VARCHAR(1024) null default null; 13 | alter table virtual_host_location modify id_upstream bigint(10) null default null; 14 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/keystore.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/nginx-admin-ui-standalone/src/main/resources/keystore.jks -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/modules/com/h2database/h2/main/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/modules/com/microsoft/sqlserver/main/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/modules/com/mysql/main/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/modules/com/oracle/main/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/modules/org/mariadb/main/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /nginx-admin-ui-standalone/src/main/resources/modules/org/postgresql/main/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/JaxRsApplication.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin; 2 | 3 | import javax.ws.rs.ApplicationPath; 4 | import javax.ws.rs.core.Application; 5 | 6 | @ApplicationPath("api") 7 | public class JaxRsApplication extends Application { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/controller/AccessLogController.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.controller; 2 | 3 | import javax.inject.Inject; 4 | 5 | import com.jslsolucoes.nginx.admin.model.Nginx; 6 | import com.jslsolucoes.nginx.admin.repository.AccessLogRepository; 7 | import com.jslsolucoes.vaptor4.misc.pagination.Paginator; 8 | 9 | import br.com.caelum.vraptor.Controller; 10 | import br.com.caelum.vraptor.Path; 11 | import br.com.caelum.vraptor.Result; 12 | 13 | @Controller 14 | @Path("accessLog") 15 | public class AccessLogController { 16 | 17 | private Result result; 18 | private AccessLogRepository accessLogRepository; 19 | private Paginator paginator; 20 | 21 | @Deprecated 22 | public AccessLogController() { 23 | 24 | } 25 | 26 | @Inject 27 | public AccessLogController(Result result, AccessLogRepository accessLogRepository, Paginator paginator) { 28 | this.result = result; 29 | this.accessLogRepository = accessLogRepository; 30 | this.paginator = paginator; 31 | } 32 | 33 | @Path("list/{idNginx}") 34 | public void list(Long idNginx) { 35 | this.result.include("nginx", new Nginx(idNginx)); 36 | this.result.include("totalResults", accessLogRepository.countFor(new Nginx(idNginx))); 37 | this.result.include("accessLogList", 38 | accessLogRepository.listAllFor(new Nginx(idNginx), paginator.start(), paginator.resultsPerPage())); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/controller/AppController.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.controller; 2 | 3 | import javax.inject.Inject; 4 | 5 | import com.jslsolucoes.nginx.admin.model.Nginx; 6 | import com.jslsolucoes.nginx.admin.repository.NginxRepository; 7 | import com.jslsolucoes.nginx.admin.ui.config.Configuration; 8 | import com.jslsolucoes.vraptor4.auth.annotation.Public; 9 | 10 | import br.com.caelum.vraptor.Controller; 11 | import br.com.caelum.vraptor.Path; 12 | import br.com.caelum.vraptor.Result; 13 | import br.com.caelum.vraptor.view.Results; 14 | 15 | @Controller 16 | public class AppController { 17 | 18 | private Configuration configuration; 19 | private Result result; 20 | private NginxRepository nginxRepository; 21 | 22 | @Deprecated 23 | public AppController() { 24 | 25 | } 26 | 27 | @Inject 28 | public AppController(Configuration configuration, Result result, NginxRepository nginxRepository) { 29 | this.configuration = configuration; 30 | this.result = result; 31 | this.nginxRepository = nginxRepository; 32 | } 33 | 34 | @Public 35 | @Path("/version") 36 | public void version() { 37 | this.result.use(Results.json()).from(configuration.getApplication().getVersion(), "version").serialize(); 38 | } 39 | 40 | @Path(value = { "/", "/home" }) 41 | public void home() { 42 | this.result.include("nginxList", nginxRepository.listAllConfigured()); 43 | } 44 | 45 | @Path("/applySessionFor/{id}") 46 | public void applyFor(Long id) { 47 | this.result.include("nginx", nginxRepository.load(new Nginx(id))); 48 | this.result.forwardTo(this).home(); 49 | } 50 | 51 | @Path("/welcome") 52 | public void welcome() { 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/controller/ErrorLogController.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.controller; 2 | 3 | import javax.inject.Inject; 4 | 5 | import com.jslsolucoes.nginx.admin.model.Nginx; 6 | import com.jslsolucoes.nginx.admin.repository.ErrorLogRepository; 7 | import com.jslsolucoes.vaptor4.misc.pagination.Paginator; 8 | 9 | import br.com.caelum.vraptor.Controller; 10 | import br.com.caelum.vraptor.Path; 11 | import br.com.caelum.vraptor.Result; 12 | 13 | @Controller 14 | @Path("errorLog") 15 | public class ErrorLogController { 16 | 17 | private Result result; 18 | private ErrorLogRepository errorLogRepository; 19 | private Paginator paginator; 20 | 21 | @Deprecated 22 | public ErrorLogController() { 23 | 24 | } 25 | 26 | @Inject 27 | public ErrorLogController(Result result, ErrorLogRepository errorLogRepository, Paginator paginator) { 28 | this.result = result; 29 | this.errorLogRepository = errorLogRepository; 30 | this.paginator = paginator; 31 | } 32 | 33 | @Path("list/{idNginx}") 34 | public void list(Long idNginx) { 35 | this.result.include("nginx", new Nginx(idNginx)); 36 | this.result.include("totalResults", errorLogRepository.countFor(new Nginx(idNginx))); 37 | this.result.include("errorLogList", 38 | errorLogRepository.listAllFor(new Nginx(idNginx), paginator.start(), paginator.resultsPerPage())); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/controller/ImportController.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.controller; 2 | 3 | import br.com.caelum.vraptor.Controller; 4 | import br.com.caelum.vraptor.Path; 5 | import br.com.caelum.vraptor.Post; 6 | import br.com.caelum.vraptor.Result; 7 | import com.jslsolucoes.nginx.admin.error.NginxAdminException; 8 | import com.jslsolucoes.nginx.admin.model.Nginx; 9 | import com.jslsolucoes.nginx.admin.repository.ImportRepository; 10 | 11 | import javax.inject.Inject; 12 | import java.io.IOException; 13 | 14 | @Deprecated 15 | @Controller 16 | @Path("import") 17 | public class ImportController { 18 | 19 | private Result result; 20 | private ImportRepository importRepository; 21 | 22 | @Deprecated 23 | public ImportController() { 24 | 25 | } 26 | 27 | @Inject 28 | public ImportController(Result result, ImportRepository importRepository) { 29 | this.result = result; 30 | this.importRepository = importRepository; 31 | } 32 | 33 | @Path("form/{idNginx}") 34 | public void form(Long idNginx) { 35 | this.result.include("nginx", new Nginx(idNginx)); 36 | } 37 | 38 | @Post 39 | public void execute(Long idNginx, String nginxConf) throws IOException, NginxAdminException { 40 | importRepository.importFrom(new Nginx(idNginx), nginxConf); 41 | this.result.include("import", true); 42 | this.result.redirectTo(this).form(idNginx); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.controller; 2 | 3 | import javax.inject.Inject; 4 | 5 | import com.jslsolucoes.vraptor4.auth.annotation.Public; 6 | 7 | import br.com.caelum.vraptor.Controller; 8 | import br.com.caelum.vraptor.Path; 9 | import br.com.caelum.vraptor.Result; 10 | 11 | @Controller 12 | @Public 13 | public class IndexController { 14 | 15 | private Result result; 16 | 17 | @Deprecated 18 | public IndexController() { 19 | 20 | } 21 | 22 | @Inject 23 | public IndexController(Result result) { 24 | this.result = result; 25 | } 26 | 27 | @Path("/favicon.ico") 28 | public void favicon() { 29 | this.result.forwardTo("/WEB-INF/jsp/index/favicon.ico"); 30 | } 31 | 32 | @Path("/robots.txt") 33 | public void robots() { 34 | this.result.forwardTo("/WEB-INF/jsp/index/robots.txt"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/controller/StrategyController.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.controller; 2 | 3 | import javax.inject.Inject; 4 | 5 | import com.jslsolucoes.nginx.admin.model.Strategy; 6 | import com.jslsolucoes.nginx.admin.repository.StrategyRepository; 7 | 8 | import br.com.caelum.vraptor.Controller; 9 | import br.com.caelum.vraptor.Path; 10 | import br.com.caelum.vraptor.Result; 11 | 12 | @Controller 13 | @Path("strategy") 14 | public class StrategyController { 15 | 16 | private Result result; 17 | private StrategyRepository strategyRepository; 18 | 19 | @Deprecated 20 | public StrategyController() { 21 | 22 | } 23 | 24 | @Inject 25 | public StrategyController(Result result, StrategyRepository strategyRepository) { 26 | this.result = result; 27 | this.strategyRepository = strategyRepository; 28 | } 29 | 30 | public void data(Long id) { 31 | this.result.include("strategy", strategyRepository.load(new Strategy(id))); 32 | } 33 | 34 | 35 | } 36 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/error/NginxAdminException.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.error; 2 | 3 | @SuppressWarnings("serial") 4 | public class NginxAdminException extends Exception { 5 | 6 | public NginxAdminException(Exception exception) { 7 | super(exception); 8 | } 9 | 10 | } 11 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/error/NginxAdminRuntimeException.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.error; 2 | 3 | @SuppressWarnings("serial") 4 | public class NginxAdminRuntimeException extends RuntimeException { 5 | 6 | public NginxAdminRuntimeException(String message) { 7 | super(message); 8 | } 9 | 10 | public NginxAdminRuntimeException(Exception exception) { 11 | super(exception); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/factory/ConfigurationFactory.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.factory; 2 | 3 | import java.util.Properties; 4 | 5 | import javax.enterprise.context.ApplicationScoped; 6 | import javax.enterprise.inject.Produces; 7 | import javax.inject.Inject; 8 | 9 | import com.jslsolucoes.cdi.misc.annotation.ApplicationProperties; 10 | import com.jslsolucoes.nginx.admin.ui.config.Configuration; 11 | import com.jslsolucoes.nginx.admin.ui.config.ConfigurationLoader; 12 | 13 | @ApplicationScoped 14 | public class ConfigurationFactory { 15 | 16 | @Inject 17 | @ApplicationProperties(name="application.properties") 18 | private Properties properties; 19 | 20 | @Produces 21 | public Configuration getInstance() { 22 | return ConfigurationLoader.newBuilder().withProperties(properties).build(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/factory/NginxAgentClientFactory.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.factory; 2 | 3 | import javax.enterprise.context.ApplicationScoped; 4 | import javax.enterprise.inject.Disposes; 5 | import javax.enterprise.inject.Produces; 6 | 7 | import com.jslsolucoes.nginx.admin.agent.client.NginxAgentClient; 8 | import com.jslsolucoes.nginx.admin.agent.client.NginxAgentClientBuilder; 9 | 10 | @ApplicationScoped 11 | public class NginxAgentClientFactory { 12 | 13 | @Produces 14 | public NginxAgentClient produces() { 15 | return NginxAgentClientBuilder.newBuilder().build(); 16 | } 17 | 18 | public void disposes(@Disposes NginxAgentClient nginxAgentClient) { 19 | nginxAgentClient.close(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/model/ResourceIdentifier.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.model; 2 | 3 | import java.io.Serializable; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.SequenceGenerator; 11 | import javax.persistence.Table; 12 | 13 | @SuppressWarnings("serial") 14 | @Entity 15 | @Table(name = "resource_identifier") 16 | @SequenceGenerator(name = "resource_identifier_sq", initialValue = 1, allocationSize = 1, sequenceName = "resource_identifier_sq") 17 | public class ResourceIdentifier implements Serializable { 18 | 19 | @Id 20 | @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "resource_identifier_sq") 21 | private Long id; 22 | 23 | @Column(name = "uuid") 24 | private String uuid; 25 | 26 | public ResourceIdentifier() { 27 | 28 | } 29 | 30 | public ResourceIdentifier(String uuid) { 31 | this.uuid = uuid; 32 | } 33 | 34 | public ResourceIdentifier(Long id) { 35 | this.id = id; 36 | } 37 | 38 | public Long getId() { 39 | return id; 40 | } 41 | 42 | public void setId(Long id) { 43 | this.id = id; 44 | } 45 | 46 | public String getUuid() { 47 | return uuid; 48 | } 49 | 50 | public void setUuid(String uuid) { 51 | this.uuid = uuid; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/AccessLogRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.model.AccessLog; 6 | import com.jslsolucoes.nginx.admin.model.Nginx; 7 | 8 | public interface AccessLogRepository { 9 | 10 | public List listAllFor(Nginx nginx, Integer firstResult, Integer maxResults); 11 | 12 | public Long countFor(Nginx nginx); 13 | 14 | public void collect(); 15 | 16 | public void rotate(); 17 | } 18 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/ConfigurationRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import com.jslsolucoes.nginx.admin.model.Configuration; 4 | import com.jslsolucoes.nginx.admin.model.Nginx; 5 | import com.jslsolucoes.nginx.admin.repository.impl.OperationResult; 6 | import com.jslsolucoes.nginx.admin.repository.impl.OperationStatusType; 7 | 8 | public interface ConfigurationRepository { 9 | 10 | 11 | public OperationStatusType deleteFor(Nginx nginx); 12 | 13 | public Configuration loadFor(Nginx nginx); 14 | 15 | public OperationResult saveOrUpdate(Configuration configuration); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/ErrorLogRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.model.ErrorLog; 6 | import com.jslsolucoes.nginx.admin.model.Nginx; 7 | 8 | public interface ErrorLogRepository { 9 | 10 | public List listAllFor(Nginx nginx, Integer firstResult, Integer maxResults); 11 | 12 | public Long countFor(Nginx nginx); 13 | 14 | public void collect(); 15 | 16 | public void rotate(); 17 | } 18 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/ImportRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import com.jslsolucoes.nginx.admin.error.NginxAdminException; 4 | import com.jslsolucoes.nginx.admin.model.Nginx; 5 | 6 | public interface ImportRepository { 7 | public void importFrom(Nginx nginx, String nginxConf) throws NginxAdminException; 8 | } 9 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/NginxRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.error.NginxAdminException; 6 | import com.jslsolucoes.nginx.admin.model.Nginx; 7 | import com.jslsolucoes.nginx.admin.repository.impl.OperationResult; 8 | import com.jslsolucoes.nginx.admin.repository.impl.OperationStatusType; 9 | 10 | public interface NginxRepository { 11 | 12 | public OperationStatusType insert(Nginx nginx); 13 | 14 | public List validateBeforeSaveOrUpdate(Nginx nginx); 15 | 16 | public OperationResult saveOrUpdate(Nginx nginx) throws NginxAdminException; 17 | 18 | public List listAll(); 19 | 20 | public List listAllConfigured(); 21 | 22 | public Nginx load(Nginx nginx); 23 | 24 | public OperationStatusType delete(Nginx nginx); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/ReportRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import java.io.InputStream; 4 | import java.util.List; 5 | 6 | import org.joda.time.LocalDate; 7 | import org.joda.time.LocalTime; 8 | 9 | import com.jslsolucoes.nginx.admin.error.NginxAdminException; 10 | import com.jslsolucoes.nginx.admin.model.Nginx; 11 | import com.jslsolucoes.nginx.admin.model.VirtualHostAlias; 12 | 13 | public interface ReportRepository { 14 | 15 | public List validateBeforeSearch(List aliases, LocalDate from, LocalTime fromTime, 16 | LocalDate to, LocalTime toTime, Nginx nginx); 17 | 18 | public InputStream statistics(List aliases, LocalDate from, LocalTime fromTime, LocalDate to, 19 | LocalTime toTime, Nginx nginx) throws NginxAdminException; 20 | 21 | } 22 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/ResourceIdentifierRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import com.jslsolucoes.nginx.admin.model.ResourceIdentifier; 4 | 5 | public interface ResourceIdentifierRepository { 6 | 7 | public ResourceIdentifier create(); 8 | 9 | public void delete(String hash); 10 | 11 | public ResourceIdentifier load(ResourceIdentifier resourceIdentifier); 12 | } 13 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/ServerRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.model.Nginx; 6 | import com.jslsolucoes.nginx.admin.model.Server; 7 | import com.jslsolucoes.nginx.admin.repository.impl.OperationResult; 8 | import com.jslsolucoes.nginx.admin.repository.impl.OperationStatusType; 9 | 10 | public interface ServerRepository { 11 | 12 | public List listAllFor(Nginx nginx); 13 | 14 | public OperationStatusType delete(Server server); 15 | 16 | public Server load(Server server); 17 | 18 | public OperationResult saveOrUpdate(Server server); 19 | 20 | public List validateBeforeSaveOrUpdate(Server server); 21 | 22 | public OperationStatusType insert(Server server); 23 | 24 | public Server searchFor(String ip, Nginx nginx); 25 | } 26 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/SslCertificateRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.model.Nginx; 6 | import com.jslsolucoes.nginx.admin.model.SslCertificate; 7 | import com.jslsolucoes.nginx.admin.repository.impl.OperationResult; 8 | import com.jslsolucoes.nginx.admin.repository.impl.OperationStatusType; 9 | 10 | public interface SslCertificateRepository { 11 | 12 | public OperationStatusType delete(SslCertificate sslCertificate); 13 | 14 | public SslCertificate load(SslCertificate sslCertificate); 15 | 16 | public OperationResult saveOrUpdate(SslCertificate sslCertificate); 17 | 18 | public List listAllFor(Nginx nginx); 19 | 20 | public List validateBeforeSaveOrUpdate(SslCertificate sslCertificate); 21 | } 22 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/StrategyRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.model.Strategy; 6 | 7 | public interface StrategyRepository { 8 | 9 | public List listAll(); 10 | 11 | public Strategy searchFor(String name); 12 | 13 | public Strategy load(Strategy strategy); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/UpstreamRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.model.Nginx; 6 | import com.jslsolucoes.nginx.admin.model.Upstream; 7 | import com.jslsolucoes.nginx.admin.model.UpstreamServer; 8 | import com.jslsolucoes.nginx.admin.repository.impl.OperationResult; 9 | import com.jslsolucoes.nginx.admin.repository.impl.OperationStatusType; 10 | 11 | public interface UpstreamRepository { 12 | 13 | public List listAllFor(Nginx nginx); 14 | 15 | public OperationStatusType delete(Upstream upstream); 16 | 17 | public Upstream load(Upstream upstream); 18 | 19 | public OperationResult saveOrUpdate(Upstream upstream, List upstreamServers); 20 | 21 | public List validateBeforeSaveOrUpdate(Upstream upstream, List upstreamServers); 22 | 23 | public Upstream searchFor(String name, Nginx nginx); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/UpstreamServerRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.model.Upstream; 6 | import com.jslsolucoes.nginx.admin.model.UpstreamServer; 7 | 8 | public interface UpstreamServerRepository { 9 | 10 | public void create(Upstream upstream, List upstreamServers); 11 | 12 | public void deleteAllFor(Upstream upstream); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/UserRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.model.User; 6 | 7 | public interface UserRepository { 8 | public User authenticate(String identification, String password); 9 | 10 | public List validateBeforeResetPasswordFor(String identification); 11 | 12 | public String resetPasswordFor(String identification); 13 | 14 | public List validateBeforeChangePassword(User user, String oldPassword, String password, 15 | String passwordConfirm); 16 | 17 | public void changePassword(User user, String password); 18 | 19 | public User loadForSession(User user); 20 | 21 | public User load(User user); 22 | 23 | public List listAll(); 24 | 25 | public List validateBeforeCreateUser(String login, String loginConfirm, String email, String password, 26 | String passwordConfirm); 27 | 28 | public void create(String login, String email, String password); 29 | } 30 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/VirtualHostAliasRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.model.Nginx; 6 | import com.jslsolucoes.nginx.admin.model.VirtualHost; 7 | import com.jslsolucoes.nginx.admin.model.VirtualHostAlias; 8 | 9 | public interface VirtualHostAliasRepository { 10 | 11 | public void recreateAllFor(VirtualHost virtualHost, List aliases); 12 | 13 | public void deleteAllFor(VirtualHost virtualHost); 14 | 15 | public List listAll(VirtualHost virtualHost); 16 | 17 | public List listAllFor(Nginx nginx); 18 | 19 | public VirtualHostAlias load(VirtualHostAlias virtualHostAlias); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/VirtualHostLocationRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.model.VirtualHost; 6 | import com.jslsolucoes.nginx.admin.model.VirtualHostLocation; 7 | 8 | public interface VirtualHostLocationRepository { 9 | 10 | public void recreateAllFor(VirtualHost virtualHost, List locations); 11 | 12 | public void deleteAllFor(VirtualHost virtualHost); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/VirtualHostRepository.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository; 2 | 3 | import java.util.List; 4 | 5 | import com.jslsolucoes.nginx.admin.model.Nginx; 6 | import com.jslsolucoes.nginx.admin.model.VirtualHost; 7 | import com.jslsolucoes.nginx.admin.model.VirtualHostAlias; 8 | import com.jslsolucoes.nginx.admin.model.VirtualHostLocation; 9 | import com.jslsolucoes.nginx.admin.repository.impl.OperationResult; 10 | import com.jslsolucoes.nginx.admin.repository.impl.OperationStatusType; 11 | 12 | public interface VirtualHostRepository { 13 | 14 | public List listAllFor(Nginx nginx); 15 | 16 | public OperationStatusType delete(VirtualHost virtualHost); 17 | 18 | public VirtualHost load(VirtualHost virtualHost); 19 | 20 | public OperationResult saveOrUpdate(VirtualHost virtualHost, List aliases, 21 | List locations); 22 | 23 | public List validateBeforeSaveOrUpdate(VirtualHost virtualHost, List aliases, 24 | List locations); 25 | 26 | public VirtualHost hasEquals(VirtualHost virtualHost, List aliases); 27 | 28 | public List searchFor(Nginx nginx, String term); 29 | } 30 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/impl/OperationResult.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository.impl; 2 | 3 | public class OperationResult { 4 | 5 | private OperationStatusType operationType; 6 | private Long id; 7 | 8 | public OperationResult(OperationStatusType operationType, Long id) { 9 | this.operationType = operationType; 10 | this.id = id; 11 | } 12 | 13 | public Long getId() { 14 | return id; 15 | } 16 | 17 | public OperationStatusType getOperationType() { 18 | return operationType; 19 | } 20 | } -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/impl/OperationStatusType.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository.impl; 2 | 3 | public enum OperationStatusType { 4 | INSERT, UPDATE, DELETE, DELETE_FAILED, INSERT_FAILED, UPDATE_FAILED 5 | } 6 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/repository/impl/StrategyRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository.impl; 2 | 3 | import javax.enterprise.context.RequestScoped; 4 | import javax.inject.Inject; 5 | import javax.persistence.EntityManager; 6 | import javax.persistence.NoResultException; 7 | import javax.persistence.criteria.CriteriaBuilder; 8 | import javax.persistence.criteria.CriteriaQuery; 9 | import javax.persistence.criteria.Root; 10 | 11 | import com.jslsolucoes.nginx.admin.model.Strategy; 12 | import com.jslsolucoes.nginx.admin.model.Strategy_; 13 | import com.jslsolucoes.nginx.admin.repository.StrategyRepository; 14 | 15 | @RequestScoped 16 | public class StrategyRepositoryImpl extends RepositoryImpl implements StrategyRepository { 17 | 18 | @Deprecated 19 | public StrategyRepositoryImpl() { 20 | 21 | } 22 | 23 | @Inject 24 | public StrategyRepositoryImpl(EntityManager entityManager) { 25 | super(entityManager); 26 | } 27 | 28 | @Override 29 | public Strategy searchFor(String name) { 30 | try { 31 | CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); 32 | CriteriaQuery criteriaQuery = criteriaBuilder.createQuery(Strategy.class); 33 | Root root = criteriaQuery.from(Strategy.class); 34 | criteriaQuery.where(criteriaBuilder.equal(root.get(Strategy_.name), name)); 35 | return entityManager.createQuery(criteriaQuery).getSingleResult(); 36 | } catch (NoResultException noResultException) { 37 | return null; 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/scheduler/task/CollectAccessLogTask.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.scheduler.task; 2 | 3 | import javax.inject.Inject; 4 | 5 | import org.quartz.SimpleScheduleBuilder; 6 | import org.quartz.Trigger; 7 | import org.quartz.TriggerBuilder; 8 | 9 | import com.jslsolucoes.nginx.admin.repository.AccessLogRepository; 10 | import com.jslsolucoes.nginx.admin.ui.config.Configuration; 11 | import com.jslsolucoes.vraptor4.auth.annotation.Public; 12 | import com.jslsolucoes.vraptor4.scheduler.SchedulerTask; 13 | 14 | import br.com.caelum.vraptor.Controller; 15 | import br.com.caelum.vraptor.Result; 16 | import br.com.caelum.vraptor.view.Results; 17 | 18 | @Controller 19 | @Public 20 | public class CollectAccessLogTask implements SchedulerTask { 21 | 22 | private AccessLogRepository accessLogRepository; 23 | private Result result; 24 | private Configuration configuration; 25 | 26 | public CollectAccessLogTask() { 27 | 28 | } 29 | 30 | @Inject 31 | public CollectAccessLogTask(Result result, AccessLogRepository accessLogRepository, Configuration configuration) { 32 | this.result = result; 33 | this.accessLogRepository = accessLogRepository; 34 | this.configuration = configuration; 35 | 36 | } 37 | 38 | @Override 39 | public void execute() { 40 | accessLogRepository.collect(); 41 | this.result.use(Results.status()).ok(); 42 | 43 | } 44 | 45 | @Override 46 | public Trigger frequency() { 47 | return TriggerBuilder.newTrigger().startNow().withSchedule(SimpleScheduleBuilder.simpleSchedule() 48 | .withIntervalInMinutes(configuration.getAccessLog().getCollect()).repeatForever()).build(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/scheduler/task/CollectErrorLogTask.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.scheduler.task; 2 | 3 | import javax.inject.Inject; 4 | 5 | import org.quartz.SimpleScheduleBuilder; 6 | import org.quartz.Trigger; 7 | import org.quartz.TriggerBuilder; 8 | 9 | import com.jslsolucoes.nginx.admin.repository.ErrorLogRepository; 10 | import com.jslsolucoes.nginx.admin.ui.config.Configuration; 11 | import com.jslsolucoes.vraptor4.auth.annotation.Public; 12 | import com.jslsolucoes.vraptor4.scheduler.SchedulerTask; 13 | 14 | import br.com.caelum.vraptor.Controller; 15 | import br.com.caelum.vraptor.Result; 16 | import br.com.caelum.vraptor.view.Results; 17 | 18 | @Controller 19 | @Public 20 | public class CollectErrorLogTask implements SchedulerTask { 21 | 22 | private ErrorLogRepository errorLogRepository; 23 | private Result result; 24 | private Configuration configuration; 25 | 26 | public CollectErrorLogTask() { 27 | 28 | } 29 | 30 | @Inject 31 | public CollectErrorLogTask(Result result, ErrorLogRepository errorLogRepository, Configuration configuration) { 32 | this.result = result; 33 | this.errorLogRepository = errorLogRepository; 34 | this.configuration = configuration; 35 | 36 | } 37 | 38 | @Override 39 | public void execute() { 40 | errorLogRepository.collect(); 41 | this.result.use(Results.status()).ok(); 42 | 43 | } 44 | 45 | @Override 46 | public Trigger frequency() { 47 | return TriggerBuilder.newTrigger().startNow().withSchedule(SimpleScheduleBuilder.simpleSchedule() 48 | .withIntervalInMinutes(configuration.getErrorLog().getCollect()).repeatForever()).build(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/scheduler/task/RotateAccessLogTask.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.scheduler.task; 2 | 3 | import javax.inject.Inject; 4 | 5 | import org.quartz.SimpleScheduleBuilder; 6 | import org.quartz.Trigger; 7 | import org.quartz.TriggerBuilder; 8 | 9 | import com.jslsolucoes.nginx.admin.repository.AccessLogRepository; 10 | import com.jslsolucoes.nginx.admin.ui.config.Configuration; 11 | import com.jslsolucoes.vraptor4.auth.annotation.Public; 12 | import com.jslsolucoes.vraptor4.scheduler.SchedulerTask; 13 | 14 | import br.com.caelum.vraptor.Controller; 15 | import br.com.caelum.vraptor.Result; 16 | import br.com.caelum.vraptor.view.Results; 17 | 18 | @Controller 19 | @Public 20 | public class RotateAccessLogTask implements SchedulerTask { 21 | 22 | private AccessLogRepository accessLogRepository; 23 | private Result result; 24 | private Configuration configuration; 25 | 26 | public RotateAccessLogTask() { 27 | 28 | } 29 | 30 | @Inject 31 | public RotateAccessLogTask(Result result, AccessLogRepository accessLogRepository, Configuration configuration) { 32 | this.result = result; 33 | this.accessLogRepository = accessLogRepository; 34 | this.configuration = configuration; 35 | 36 | } 37 | 38 | @Override 39 | public void execute() { 40 | accessLogRepository.rotate(); 41 | this.result.use(Results.status()).ok(); 42 | } 43 | 44 | @Override 45 | public Trigger frequency() { 46 | return TriggerBuilder.newTrigger().startNow().withSchedule(SimpleScheduleBuilder.simpleSchedule() 47 | .withIntervalInMinutes(configuration.getAccessLog().getRotate()).repeatForever()).build(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/scheduler/task/RotateErrorLogTask.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.scheduler.task; 2 | 3 | import javax.inject.Inject; 4 | 5 | import org.quartz.SimpleScheduleBuilder; 6 | import org.quartz.Trigger; 7 | import org.quartz.TriggerBuilder; 8 | 9 | import com.jslsolucoes.nginx.admin.repository.ErrorLogRepository; 10 | import com.jslsolucoes.nginx.admin.ui.config.Configuration; 11 | import com.jslsolucoes.vraptor4.auth.annotation.Public; 12 | import com.jslsolucoes.vraptor4.scheduler.SchedulerTask; 13 | 14 | import br.com.caelum.vraptor.Controller; 15 | import br.com.caelum.vraptor.Result; 16 | import br.com.caelum.vraptor.view.Results; 17 | 18 | @Controller 19 | @Public 20 | public class RotateErrorLogTask implements SchedulerTask { 21 | 22 | private ErrorLogRepository errorLogRepository; 23 | private Result result; 24 | private Configuration configuration; 25 | 26 | public RotateErrorLogTask() { 27 | 28 | } 29 | 30 | @Inject 31 | public RotateErrorLogTask(Result result, ErrorLogRepository errorLogRepository, Configuration configuration) { 32 | this.result = result; 33 | this.errorLogRepository = errorLogRepository; 34 | this.configuration = configuration; 35 | 36 | } 37 | 38 | @Override 39 | public void execute() { 40 | errorLogRepository.rotate(); 41 | this.result.use(Results.status()).ok(); 42 | } 43 | 44 | @Override 45 | public Trigger frequency() { 46 | return TriggerBuilder.newTrigger().startNow().withSchedule(SimpleScheduleBuilder.simpleSchedule() 47 | .withIntervalInMinutes(configuration.getErrorLog().getRotate()).repeatForever()).build(); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/java/com/jslsolucoes/nginx/admin/session/UserSession.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.session; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import javax.enterprise.context.SessionScoped; 7 | import javax.inject.Named; 8 | 9 | import com.jslsolucoes.nginx.admin.model.User; 10 | import com.jslsolucoes.vraptor4.auth.model.AuthFunctionality; 11 | import com.jslsolucoes.vraptor4.auth.model.AuthUser; 12 | import com.jslsolucoes.vraptor4.auth.model.AuthUserSession; 13 | 14 | @SuppressWarnings("serial") 15 | @SessionScoped 16 | @Named 17 | public class UserSession implements Serializable, AuthUserSession { 18 | 19 | private User user; 20 | 21 | public void logout() { 22 | this.user = null; 23 | } 24 | 25 | public User getUser() { 26 | return user; 27 | } 28 | 29 | public void setUser(User user) { 30 | this.user = user; 31 | } 32 | 33 | @Override 34 | public List authFunctionalities() { 35 | return null; 36 | } 37 | 38 | @Override 39 | public AuthUser user() { 40 | return user; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | org.hibernate.ejb.HibernatePersistence 7 | java:jboss/datasources/nginx-admin 8 | 9 | com.jslsolucoes.nginx.admin.model.User 10 | com.jslsolucoes.nginx.admin.model.Nginx 11 | com.jslsolucoes.nginx.admin.model.Configuration 12 | com.jslsolucoes.nginx.admin.model.SslCertificate 13 | com.jslsolucoes.nginx.admin.model.Strategy 14 | com.jslsolucoes.nginx.admin.model.Server 15 | com.jslsolucoes.nginx.admin.model.Upstream 16 | com.jslsolucoes.nginx.admin.model.UpstreamServer 17 | com.jslsolucoes.nginx.admin.model.VirtualHost 18 | com.jslsolucoes.nginx.admin.model.VirtualHostAlias 19 | com.jslsolucoes.nginx.admin.model.VirtualHostLocation 20 | com.jslsolucoes.nginx.admin.model.ResourceIdentifier 21 | com.jslsolucoes.nginx.admin.model.AccessLog 22 | com.jslsolucoes.nginx.admin.model.ErrorLog 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # Root logger option 2 | log4j.rootLogger=INFO, stdout 3 | 4 | # Direct log messages to stdout 5 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 6 | log4j.appender.stdout.Target=System.out 7 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 8 | log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n 9 | 10 | log4j.logger.org.shredzone.acme4j = DEBUG -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/resources/report/image/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/nginx-admin-ui/src/main/resources/report/image/logo.png -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/resources/report/statistics.jasper: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/nginx-admin-ui/src/main/resources/report/statistics.jasper -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/app/edit.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="../app/taglibs.jsp"%> 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 12 | 13 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/app/error.jsp: -------------------------------------------------------------------------------- 1 | <%@page isErrorPage="true"%> 2 | <%@include file="taglibs.jsp"%> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | : 15 | 16 | 17 | ${pageContext.errorData.requestURI} 18 | 19 | 20 | 21 | 22 | : 23 | 24 | 25 | ${pageContext.errorData.statusCode} 26 | 27 | 28 | 29 | 30 | : 31 | 32 | 33 | ${ x:fullStackTrace(pageContext.exception) } 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/app/forbidden.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="taglibs.jsp"%> 2 | 3 | 4 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/app/notFound.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="taglibs.jsp"%> 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/app/taglibs.jsp: -------------------------------------------------------------------------------- 1 | <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 2 | <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> 3 | <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> 4 | <%@ taglib uri="http://tagrialib.jslsolucoes.com/tags/html" prefix="html"%> 5 | <%@ taglib uri="http://tagrialib.jslsolucoes.com/tags/ajax" prefix="ajax"%> 6 | <%@ taglib uri="http://tagrialib.jslsolucoes.com/tags/x" prefix="x"%> -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/app/welcome.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="taglibs.jsp"%> 2 | 3 | 4 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/errorLog/list.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="../app/taglibs.jsp"%> 2 | 3 | 4 | 6 | 7 | ${ errorLog.timestamp } 8 | 9 | 10 | ${ errorLog.level } 11 | 12 | 13 | ${ errorLog.pid } 14 | 15 | 16 | ${ errorLog.tid } 17 | 18 | 19 | ${ errorLog.cid } 20 | 21 | 22 | ${ errorLog.message } 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/import/form.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="../app/taglibs.jsp"%> 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/index/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/nginx-admin-ui/src/main/webapp/WEB-INF/jsp/index/favicon.ico -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/index/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: / -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/nginx/reload.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="../app/taglibs.jsp"%> 2 | 3 | 4 | 6 | 8 | 9 | 10 | window.setTimeout(function(){ 11 | window.parent.self.location = URL_BASE + '/nginx/tabs/${ id }'; 12 | },5000); 13 | 14 | 15 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/nginx/tabs.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="../app/taglibs.jsp"%> 2 | 3 | 4 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/server/form.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="../app/taglibs.jsp"%> 2 | 3 | 4 | 5 | 7 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/server/list.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="../app/taglibs.jsp"%> 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ${ server.ip } 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/settings/app.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="../app/taglibs.jsp"%> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ${ application.version } 11 | 12 | 13 | 14 | ${ application.urlBase } 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/settings/home.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="../app/taglibs.jsp"%> 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/strategy/data.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="../app/taglibs.jsp"%> 2 | 3 | ${ strategy.description } 4 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/user/changePassword.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="../app/taglibs.jsp"%> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 17 | 18 | 19 | 21 | 22 | 23 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/WEB-INF/jsp/user/resetPassword.jsp: -------------------------------------------------------------------------------- 1 | <%@include file="../app/taglibs.jsp"%> 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | - 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /nginx-admin-ui/src/main/webapp/image/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alibaba/nginx-admin-plus/b48b05cbcc537c63b39f0ccc5b37c03bba96f9d6/nginx-admin-ui/src/main/webapp/image/logo.png -------------------------------------------------------------------------------- /nginx-admin-ui/src/test/java/com/jslsolucoes/nginx/admin/repository/impl/UserRepositoryImplTest.java: -------------------------------------------------------------------------------- 1 | package com.jslsolucoes.nginx.admin.repository.impl; 2 | 3 | import org.apache.commons.codec.digest.DigestUtils; 4 | import org.junit.Assert; 5 | import org.junit.Test; 6 | 7 | public class UserRepositoryImplTest { 8 | 9 | @Test public void authenticate() { 10 | String sha256Hex = DigestUtils.sha256Hex("admin"); 11 | 12 | Assert.assertEquals("8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918", sha256Hex); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | com.jslsolucoes 5 | nginx-admin 6 | 2.0.3 7 | pom 8 | 9 | 10 | 1.8 11 | 1.8 12 | 1.8 13 | UTF-8 14 | 15 | 16 | 17 | nginx-admin-parser 18 | nginx-admin-agent-model 19 | nginx-admin-ui-configuration 20 | nginx-admin-database 21 | nginx-admin-agent-configuration 22 | nginx-admin-agent-client 23 | nginx-admin-agent 24 | nginx-admin-ui 25 | nginx-admin-ui-standalone 26 | nginx-admin-agent-standalone 27 | 28 | 29 | 30 | 31 | 32 | 33 | org.apache.maven.plugins 34 | maven-compiler-plugin 35 | 3.1 36 | 37 | ${java.version} 38 | ${java.version} 39 | 40 | -Xlint 41 | -parameters 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | jbosspublic 19 | jboss public 20 | http://repository.jboss.org/nexus/content/groups/public-jboss/ 21 | jboss-public-repository-group 22 | 23 | 24 | 25 | 26 | --------------------------------------------------------------------------------