Created
September 25, 2019 06:43
-
-
Save arthurtsang/1d79920e8b88dc83337b4ae430adaeab to your computer and use it in GitHub Desktop.
nginx config for git server
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
# Default server configuration | |
# | |
server { | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
root /var/www/html/git; | |
# Add index.php to the list if you are using PHP | |
index index.html index.htm index.nginx-debian.html; | |
server_name _; | |
location / { | |
# First attempt to serve request as file, then | |
# as directory, then fall back to displaying a 404. | |
try_files $uri $uri/ =404; | |
} | |
location ~ (/.*) { | |
client_max_body_size 0; # Git pushes can be massive, just to make sure nginx doesn't suddenly cut the connection add this. | |
include /etc/nginx/fastcgi_params; # Include the default fastcgi configs | |
fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; # Tells fastcgi to pass the request to the git http backend executable | |
fastcgi_param GIT_HTTP_EXPORT_ALL ""; | |
fastcgi_param GIT_PROJECT_ROOT /var/www/html/git; | |
fastcgi_param REMOTE_USER $remote_user; | |
fastcgi_param PATH_INFO $1; # Takes the capture group from our location directive and gives git that. | |
fastcgi_pass unix:/var/run/fcgiwrap.socket; # Pass the request to fastcgi | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment