Categories
Nginx

How to configure your Nginx Virtual Host ?

Hi team, here is what to add in your nginx configuration file to resolve the desired virtual host name

 server_name example.com www.example.com;
Categories
Nginx

NGINX Configuration BLOCK URLS

location ~* ^/log(\/)?$ { 
    return 404; 
}
 
location ~* ^/swagger(.*)$ { 
    return 404; 
}
Categories
Nginx Web API

CORS ISSUE NGINX SWAGGER FETCH ERROR SOLUTION – Jeeezzz !

CORS Solution for NGINX SWAGGER

set $origin $http_origin; 

if ($origin !~ '^https?://(docs-mapi)\.4over\.com) {
 set $origin 'https://yourdomain.com';
 }

add_header 'Access-Control-Allow-Origin' "$origin" always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, DELETE, PUT, PATCH, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' 'Authorization, Access Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers, api_key' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';