Answer the question
In order to leave comments, you need to log in
How to redirect by context path using nginx as an example?
I want to implement a git server on an aws instance (based on scm-manager), I want to take it out via a contextual link. What would look like https://ip/git Tell me how to implement this? by analogy, I have a config for jenkins which I successfully output through the config and it is available along the path https://ip/jenkins:
upstream jenkins {
keepalive 32; # keepalive connections
server 127.0.0.1:8080; # git ip and port
}
server {
listen 443 http2 ssl;
listen [::]:443 http2 ssl;
server_name xxxx;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_ecdh_curve secp384r1;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
# Disable preloading HSTS for now. You can use the commented out header line that includes
# the "preload" directive if you understand the implications.
#add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
root /var/lib/git;
location / {
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;
# Fix the “It appears that your reverse proxy set up is broken" error.
proxy_read_timeout 90;
proxy_pass http://127.0.0.1:8080;
proxy_redirect 127.0.0.1:8080 https://xxxx/git;
}
error_page 404 /404 .html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
Answer the question
In order to leave comments, you need to log in
location /git/ {
proxy_pass http://127.0.0.1:8080/;
proxy_redirect http://127.0.0.1:8080 https://x.x.x.x/git;
}
it is not clear why you did not make a separate location in the config where jenkins is, it is not clear why you need a redirect there,
do you even understand what you are doing?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question