Skip to content

Commit f9a9995

Browse files
committed
Added nginx configuration files
1 parent 51dad18 commit f9a9995

3 files changed

Lines changed: 255 additions & 0 deletions

File tree

nginx/nginx.conf

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
user www-data;
2+
worker_processes auto;
3+
pid /run/nginx.pid;
4+
include /etc/nginx/modules-enabled/*.conf;
5+
6+
events {
7+
worker_connections 768;
8+
# multi_accept on;
9+
}
10+
11+
http {
12+
13+
##
14+
# Basic Settings
15+
##
16+
17+
sendfile on;
18+
tcp_nopush on;
19+
types_hash_max_size 2048;
20+
# server_tokens off;
21+
22+
# server_names_hash_bucket_size 64;
23+
# server_name_in_redirect off;
24+
25+
include /etc/nginx/mime.types;
26+
default_type application/octet-stream;
27+
28+
##
29+
# SSL Settings
30+
##
31+
32+
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
33+
ssl_prefer_server_ciphers on;
34+
35+
##
36+
# Logging Settings
37+
##
38+
39+
access_log /var/log/nginx/access.log;
40+
error_log /var/log/nginx/error.log;
41+
42+
##
43+
# Gzip Settings
44+
##
45+
46+
gzip on;
47+
48+
# gzip_vary on;
49+
# gzip_proxied any;
50+
# gzip_comp_level 6;
51+
# gzip_buffers 16 8k;
52+
# gzip_http_version 1.1;
53+
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
54+
55+
##
56+
# Virtual Host Configs
57+
##
58+
59+
include /etc/nginx/conf.d/*.conf;
60+
include /etc/nginx/sites-enabled/*;
61+
}
62+
63+
stream {
64+
server {
65+
listen 8644;
66+
67+
# SSL certificates
68+
# ssl_certificate /etc/letsencrypt/live/ims-project.cs.bgu.ac.il/fullchain.pem;
69+
# ssl_certificate_key /etc/letsencrypt/live/ims-project.cs.bgu.ac.il/privkey.pem;
70+
71+
proxy_connect_timeout 60s;
72+
proxy_socket_keepalive on;
73+
proxy_pass localhost:5432;
74+
}
75+
}
76+
77+
78+
#mail {
79+
# # See sample authentication script at:
80+
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
81+
#
82+
# # auth_http localhost/auth.php;
83+
# # pop3_capabilities "TOP" "USER";
84+
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
85+
#
86+
# server {
87+
# listen localhost:110;
88+
# protocol pop3;
89+
# proxy on;
90+
# }
91+
#
92+
# server {
93+
# listen localhost:143;
94+
# protocol imap;
95+
# proxy on;
96+
# }
97+
#}

nginx/sites-available/default

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Redirect HTTP traffic to HTTPS
2+
server {
3+
listen 80;
4+
listen [::]:80;
5+
server_name ims-project.cs.bgu.ac.il;
6+
7+
# Serve .well-known/acme-challenge before redirecting to HTTPS
8+
location ^~ /.well-known/acme-challenge/ {
9+
root /var/www/html;
10+
allow all;
11+
}
12+
13+
# Redirect all HTTP traffic to HTTPS
14+
if ($host = ims-project.cs.bgu.ac.il) {
15+
return 301 https://$host$request_uri;
16+
} # managed by Certbot
17+
}
18+
19+
# HTTPS server block
20+
server {
21+
listen 443 ssl;
22+
listen [::]:443 ssl;
23+
24+
server_name ims-project.cs.bgu.ac.il;
25+
26+
# SSL certificates
27+
ssl_certificate /etc/letsencrypt/live/ims-project.cs.bgu.ac.il/fullchain.pem; # managed by Certbot
28+
ssl_certificate_key /etc/letsencrypt/live/ims-project.cs.bgu.ac.il/privkey.pem; # managed by Certbot
29+
30+
# Improve SSL security
31+
ssl_protocols TLSv1.2 TLSv1.3;
32+
ssl_prefer_server_ciphers on;
33+
ssl_ciphers HIGH:!aNULL:!MD5;
34+
35+
# Root directory
36+
root /var/www/html;
37+
38+
# Add index.php to the list if you are using PHP
39+
index index.html index.htm index.nginx-debian.html;
40+
41+
location ^~ /.well-known/acme-challenge/ {
42+
root /var/www/html;
43+
allow all;
44+
}
45+
46+
# Location for serving requests
47+
location / {
48+
# Proxy requests to Flask application
49+
proxy_pass http://127.0.0.1:5000;
50+
proxy_set_header Host $host;
51+
proxy_set_header X-Real-IP $remote_addr;
52+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
53+
proxy_set_header X-Forwarded-Proto $scheme;
54+
}
55+
56+
# Deny access to .htaccess files if present
57+
location ~ /\.ht {
58+
deny all;
59+
}
60+
61+
}

nginx/sites-available/ims-project

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
server {
2+
listen 80;
3+
listen [::]:80;
4+
5+
server_name manager-http;
6+
7+
# Redirect all HTTP traffic to HTTPS
8+
return 301 https://$host$request_uri;
9+
}
10+
11+
server {
12+
listen 443 ssl;
13+
listen [::]:443 ssl;
14+
15+
server_name manager-https;
16+
17+
# SSL certificates
18+
ssl_certificate /etc/letsencrypt/live/ims-project.cs.bgu.ac.il/fullchain.pem;
19+
ssl_certificate_key /etc/letsencrypt/live/ims-project.cs.bgu.ac.il/privkey.pem;
20+
21+
# Improve SSL security
22+
ssl_protocols TLSv1.2 TLSv1.3;
23+
ssl_prefer_server_ciphers on;
24+
ssl_ciphers HIGH:!aNULL:!MD5;
25+
26+
# Root directory
27+
root /var/www/html;
28+
29+
# Add index.php to the list if you are using PHP
30+
index index.html index.htm index.nginx-debian.html;
31+
32+
# Location for serving requests
33+
location / {
34+
proxy_pass http://127.0.0.1:5000;
35+
proxy_set_header Host $host;
36+
proxy_set_header X-Real-IP $remote_addr;
37+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
38+
proxy_set_header X-Forwarded-Proto $scheme;
39+
}
40+
41+
# Deny access to .htaccess files if present
42+
location ~ /\.ht {
43+
deny all;
44+
}
45+
}
46+
47+
server {
48+
listen 8640 ssl;
49+
listen [::]:8640 ssl;
50+
51+
server_name game-server;
52+
53+
# SSL certificates
54+
ssl_certificate /etc/letsencrypt/live/ims-project.cs.bgu.ac.il/fullchain.pem;
55+
ssl_certificate_key /etc/letsencrypt/live/ims-project.cs.bgu.ac.il/privkey.pem;
56+
57+
# WebSocket traffic
58+
location /ws {
59+
proxy_pass http://127.0.0.1:8080;
60+
proxy_http_version 1.1;
61+
proxy_set_header Upgrade $http_upgrade;
62+
proxy_set_header Connection "Upgrade";
63+
proxy_set_header Host $host;
64+
proxy_set_header X-Real-IP $remote_addr;
65+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
66+
proxy_set_header X-Forwarded-Proto $scheme;
67+
}
68+
69+
# All other requests (REST API, static files, etc.)
70+
location / {
71+
proxy_pass http://127.0.0.1:8080;
72+
proxy_set_header Host $host;
73+
proxy_set_header X-Real-IP $remote_addr;
74+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
75+
proxy_set_header X-Forwarded-Proto $scheme;
76+
}
77+
}
78+
79+
server {
80+
listen 8645 ssl;
81+
listen [::]:8645 ssl;
82+
83+
server_name server-manager;
84+
85+
# SSL certificates
86+
ssl_certificate /etc/letsencrypt/live/ims-project.cs.bgu.ac.il/fullchain.pem;
87+
ssl_certificate_key /etc/letsencrypt/live/ims-project.cs.bgu.ac.il/privkey.pem;
88+
89+
# Location for serving requests
90+
location / {
91+
proxy_pass http://127.0.0.1:8085;
92+
proxy_set_header Host $host:$server_port;
93+
proxy_set_header X-Real-IP $remote_addr;
94+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
95+
proxy_set_header X-Forwarded-Proto $scheme;
96+
}
97+
}

0 commit comments

Comments
 (0)