lunaiwa / student-template

https://lunaiwa.github.io/student-template/
MIT License
2 stars 0 forks source link

Pop Quiz 1/30 #16

Open lunaiwa opened 8 months ago

lunaiwa commented 8 months ago

Reverse Proxy

Server Name: Server name in Nginx specifies the domain name associated with server block

Reverse Proxy: Nginx is used as the reverse proxy to forward the cilent requests to backend servers

Proxy Pass: Used to define the backend server address > requests forwarded there

server {
   listen 80;
    listen [::]:80;
    ✦server_name (SERVERNAMEHERE).stu.nighthawkcodingsociety.com ; # server namer>basically links the domain name to nginx for the server configuration. 
    # Configure CORS Headers
    location / { 
       ✦proxy_pass http://localhost:8---; #  proxy pass>will then forward the requests made to the server with the “tag” for the domain name to the proxy_pass, which is the address for the localhost backend server corresponding to the domain name with server_name.
        # Simple requests
        if ($request_method ~* "(GET|POST|PUT|DELETE)") { # Customize Request methods based on your needs
                add_header "Access-Control-Allow-Origin"  *;
        }
        # Preflighted requests 
        if ($request_method = OPTIONS ) {
                add_header "Access-Control-Allow-Origin"  *;
                add_header "Access-Control-Allow-Methods" "GET, POST, PUT, DELETE, OPTIONS, HEAD"; # Make sure the request methods above match here
                add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
                return 200;
        }
    }
}

0.9

lunaiwa commented 8 months ago

JWT Login Process

JWT Cookie > Authentication >

lunaiwa commented 8 months ago

Security Config

Security Config Rules:

Rules:

@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
                // Permit all requests to "/public/**"
                .antMatchers("/public/**").permitAll()
                // Require authentication for other requests
                .anyRequest().authenticated()
                .and()
            .formLogin()
                // Customize login page and login processing URL if needed
                .loginPage("/login")
                .permitAll()
                .and()
            .logout()
                .permitAll();
    }
}
lunaiwa commented 8 months ago

POJO

POJO: "Plain Old Java Object"

POJO Characteristics:

To Change POJO

lunaiwa commented 8 months ago

Docker

Docker:

Commands to make Docker update: