-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from go-park-mail-ru/task/TRI-19
Nginx
- Loading branch information
Showing
6 changed files
with
93 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
module TripAdvisor | ||
|
||
go 1.22.7 | ||
|
||
require github.com/gorilla/mux v1.8.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= | ||
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
user www-data; | ||
worker_processes auto; | ||
pid /run/nginx.pid; | ||
error_log /var/log/nginx/error.log; | ||
include /etc/nginx/modules-enabled/*.conf; | ||
|
||
events { | ||
worker_connections 768; | ||
# multi_accept on; | ||
} | ||
|
||
http { | ||
|
||
## | ||
# Basic Settings | ||
## | ||
|
||
sendfile on; | ||
tcp_nopush on; | ||
types_hash_max_size 2048; | ||
include /etc/nginx/mime.types; | ||
server { | ||
listen 80; | ||
server_name 109.120.181.229; | ||
access_log /var/log/nginx/access.log; | ||
error_log /var/log/nginx/error.log; | ||
location / { | ||
root /home/ubuntu/public; | ||
try_files $uri /index.html; | ||
} | ||
location /api/ { | ||
proxy_pass http://localhost:8080; | ||
} | ||
} | ||
|
||
## | ||
# Logging Settings | ||
## | ||
|
||
access_log /var/log/nginx/access.log; | ||
|
||
## | ||
# Gzip Settings | ||
## | ||
|
||
gzip on; | ||
|
||
include /etc/nginx/conf.d/*.conf; | ||
include /etc/nginx/sites-enabled/*; | ||
|
||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package middleware | ||
|
||
import "net/http" | ||
|
||
func CORSMiddleware(next http.Handler) http.Handler { | ||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
w.Header().Set("Access-Control-Allow-Methods", "POST,PUT,DELETE,GET") | ||
w.Header().Set("Access-Control-Allow-Headers", "Content-Type") | ||
w.Header().Set("Access-Control-Allow-Credentials", "true") | ||
w.Header().Set("Access-Control-Allow-Origin", r.Header.Get("Origin")) | ||
if r.Method == http.MethodOptions { | ||
return | ||
} | ||
next.ServeHTTP(w, r) | ||
}) | ||
} |