How to install certbot ssl certificate on nginx server

I am using centos 7.4 server. you can use following commands for installing ssl certicate.

#cd /etc/nginx/conf.d/

[root@vps147238 conf.d]# cp m.eparinay.com.conf qa.eparinay.com.conf
[root@vps147238 conf.d]# vim qa.eparinay.com.conf
[root@vps147238 conf.d]# sudo certbot --nginx -d qa.eparinay.com -d qa.eparinay.com
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Starting new HTTPS connection (1): acme-v02.api.letsencrypt.org
Attempting to parse the version 1.23.0 renewal configuration file found at /etc/letsencrypt/renewal/eparinay.com.conf with version 1.11.0 of Certbot. This might not work.
Attempting to parse the version 1.23.0 renewal configuration file found at /etc/letsencrypt/renewal/purabtech.com.conf with version 1.11.0 of Certbot. This might not work.
Attempting to parse the version 1.23.0 renewal configuration file found at /etc/letsencrypt/renewal/www.eparinay.com-0001.conf with version 1.11.0 of Certbot. This might not work.
Requesting a certificate for qa.eparinay.com
Performing the following challenges:
http-01 challenge for qa.eparinay.com
Waiting for verification…
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/qa.eparinay.com.conf
Traffic on port 80 already redirecting to ssl in /etc/nginx/conf.d/qa.eparinay.com.conf


Congratulations! You have successfully enabled https://qa.eparinay.com


IMPORTANT NOTES:

  • Congratulations! Your certificate and chain have been saved at:
    /etc/letsencrypt/live/qa.eparinay.com/fullchain.pem
    Your key file has been saved at:
    /etc/letsencrypt/live/qa.eparinay.com/privkey.pem
    Your certificate will expire on 2022-07-31. To obtain a new or
    tweaked version of this certificate in the future, simply run
    certbot again with the "certonly" option. To non-interactively
    renew all of your certificates, run "certbot renew"
  • If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
    Donating to EFF: https://eff.org/donate-le

[root@vps147238 conf.d]# vim qa.eparinay.com.conf
[root@vps147238 conf.d]# service nginx restart
Redirecting to /bin/systemctl restart nginx.service
[root@vps147238 conf.d]#

Solved: nginx Error with Permissions-Policy header: Parse of permissions policy failed because of errors reported by structured header parser

I am using Nginx server and with that, I am using an angular application. The application is running fine but in the console, I got the following error

Error with Permissions-Policy header: Parse of permissions policy failed because of errors reported by structured header parser

To solve this error I added following code in my nginx configuration.

location ^~ / {

    proxy_pass http://127.0.0.1:4200;
    add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload';

    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;

    proxy_http_version 1.1;
    proxy_cache_bypass $http_upgrade;

}

This solved my issue.

how to install micronaut on windows 10 – java

  1. install wsl on windows

run cmd as command prompt

wsl --install

Above command will enable the required optional components, download the latest Linux kernel, set WSL 2 as your default, and install a Linux distribution for you (Ubuntu by default)

  1. install sdkman – ref taken from https://sdkman.io/install
curl -s "https://beta.sdkman.io" | bash
#sdk selfupdate force
  1. install micronaut with sdkman
#sdk update
#sdk install micronaut

OR

Download the latest binary from Micronaut Website – https://github.com/micronaut-projects/micronaut-starter/releases/download/v3.2.0/micronaut-cli-3.2.0.zip

Extract the binary to appropriate location (For example: C:\PURAB\micronaut-cli-3.2.0)

Create an environment variable MICRONAUT_HOME which points to the installation directory i.e. C:\PURAB\micronaut-cli-3.2.0

Update the PATH environment variable, append %MICRONAUT_HOME%\bin.

Solved: intellij java: package javax.servlet.http does not exist

While running java web project I got following error.

java: package javax.servlet does not exist

Two solve you need to add javax.servlet-3.0.jar file in your project or ide while executing code

you can download jar from this URL:

http://www.java2s.com/Code/Jar/j/Downloadjavaxservlet30jar.htm

Solution:

File -> Project Structure->Libraries

and add javax.servlet-3.0.jar library

Detail can found in this video

java: package javax.servlet.http does not exist

java mariadb executeQuery right syntax to use near ‘? mapping exception

I was using following code

String sql = "select * from user where username=? and password=?";
PreparedStatement ps =connection.prepareStatement(sql);
ps.setString(1, username);

ps.setString(2, password);
ResultSet rs=ps.executeQuery(sql);
while (rs.next()) {
user= new User();
user.setId(rs.getInt(1));
user.setName(rs.getString(2));
user.setEmail(rs.getString(3));
user.setQualification(rs.getString(5));
user.setRole(rs.getString(6));
}

I got following eror:

java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '? and password=?' at line 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.StatementImpl.executeQuery(StatementImpl.java:1200)

Solution and what is wrong?

for this line ResultSet rs=ps.executeQuery(sql); I do not need to add SQL query there.

I removed SQL keyword it code started working fine…

String sql = "select * from user where username=? and password=?";
PreparedStatement ps =connection.prepareStatement(sql);

ps.setString(1, username);
ps.setString(2, password);
ResultSet rs=ps.executeQuery();

SSL certificate integration in Spring boot Project

SSL certificate integration

SSL certificate setting applied in application.properties file To generate self signed SSL certificate use following command:

cd src/main/resources
keytool -genkeypair -alias local_ssl -keyalg RSA -keysize 2048 -storetype PKCS12 -keystore local-ssl.p12 -validity 365 -ext san=dns:localhost

Put following code into application.properties file

spring.application.name=ssl-certificate
server.port=8443
#server.port=8080
server.ssl.enabled: true
server.ssl.key-alias: local_ssl
server.ssl.key-store: classpath:local-ssl.p12
server.ssl.key-store-type: PKCS12
server.ssl.key-password: 12345678
server.ssl.key-store-password: 12345678

Open this URL:
https://localhost:8443/

For production use following command and use p12 file in application Convert .crt to .p12

openssl pkcs12 -export -out server.p12 -inkey server.key -in server.crt

Where server.key , is the server key . server.crt is cert file from CA or self sign

you can find source code here:

https://github.com/purab/ssl-certificate-spring-boot

Jenkins installation on ubuntu OS

Use following command for jenkins installtion

  • sudo apt update
  • sudo apt install openjdk-8-jdk
  • apt install openjdk-8-jdk -y
  • wget -q -O – https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add –
  • sudo sh -c ‘echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list’
  • apt-get update
  • -sudo apt-get install jenkins -y
  • systemctl status jenkins
  • sudo ufw allow 8080
  • give sudo permisssion to jenkins user < /br> vi /etc/sudoers and add below entry jenkins ALL=(ALL) NOPASSWD: ALL and save the file

If you are getting this error

https://pkg.jenkins.io/debian-stable binary/ Release Certificate verification failed:

Then run following command

sudo su

apt update

apt-get install jenkins -y