NGinx: set localhost/project to project git folder -
i working on small website in free time. development, keep git repositories in ~/git. possible configurate nginx if go localhost/a or localhost/b, use ~/git/a , ~/git/b respectively?
i using fedora , tried single repo, keep getting 404:
/etc/nginx/nginx.conf
user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; events { worker_connections 1024; } http { 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; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; server { listen 80; server_name localhost; root /home/martenbe/git/; index index.html index.php; location /a/ { alias /home/martenbe/git/a/; } } server { listen 80 default_server; listen [::]:80 default_server; server_name _; root /usr/share/nginx/html; # load configuration files default server block. include /etc/nginx/default.d/*.conf; location / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } }
i think following should work you.
server { listen 80; server_name localhost; root /home/martenbe/git/; index index.html index.php; }
you don't need add location
module because have defined root
. if try localhost/a/index.html, nginx try find under /home/martenbe/git/a/index.html.
what requests trying ?
Comments
Post a Comment