I am new to using nginx. I am creating a homelab and trying to use this as reverse proxy
I have created this config
events {}
http {
# Define MIME types
include /etc/nginx/mime.types; # Ensure this file is included
default_type application/octet-stream;
# Global settings to reduce redundancy
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log warn;
limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
# HTTP server block to redirect all HTTP requests to HTTPS
server {
listen 80;
server_name _; # Accepts all hosts
# Redirect HTTP to HTTPS
location / {
return 301 https://$host$request_uri;
}
}
# HTTPS server block for secure connections
server {
listen 443 ssl;
server_name _; # Accepts all hosts
# SSL certificates for HTTPS
ssl_certificate /etc/nginx/certs/fullchain.pem;
ssl_certificate_key /etc/nginx/certs/privkey.pem;
# Strong SSL settings for security
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384';
ssl_prefer_server_ciphers on;
# Proxy configuration for each backend service (using separate location blocks)
# Heimdall Service
location /gity/ {
proxy_pass http://127.0.0.1:85;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
}
location /heimdall {
return 301 http://$host/;
}
location /portainer {
return 301 https://$host:9443/;
}
location /deluge {
return 301 http://$host:8112/;
}
location /excalidraw {
return 301 http://$host:3005/;
}
location /ittools {
return 301 http://$host:3080/;
}
location /jellyfin {
return 301 http://$host:8096/;
}
location /speedtest {
return 301 http://$host:3000/;
}
location /minio {
return 301 http://$host:9002/;
}
location /downloader {
return 301 http://$host:8113/;
}
location /bitwarden {
return 301 https://$host:2000/;
}
location /discord {
return 301 http://$host:3050/;
}
location /filebrowser {
return 301 http://$host:8080/;
}
location /gitlab {
return 301 http://$host:85/;
}
location /webmin {
return 301 https://$host:10000/;
}
location /postgresdb {
return 301 http://$host:5050/;
}
location /mongodb {
return 301 http://$host:5051/;
}
location /sonarqube {
return 301 http://$host:4000/;
}
location /yt-downloader {
return 301 http://$host:8998/;
}
# Additional SSL configurations as needed
}
}
I want to use url like https://maximus.local/gitlab and it should internally redirect all the requests to http://maximus.local:85.
I created a temp path /gity/ to test this but https://maximus.local/gity/ is redirecting to https://maximus.local/users/sign_in but it should be https://maximus.local/gity/users/sign_in