惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
云风的 BLOG
云风的 BLOG
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Recent Announcements
Recent Announcements
IT之家
IT之家
Google DeepMind News
Google DeepMind News
罗磊的独立博客
爱范儿
爱范儿
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
U
Unit 42
MongoDB | Blog
MongoDB | Blog
S
SegmentFault 最新的问题
B
Blog
博客园 - 叶小钗
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
C
Check Point Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

Ittavern.com

Wimage - Hosting Open-Source Image Uploader with Podman and external S3 Storage Switching from Hugo to picopaper Encryption using SSH Keys with age in Linux ETag in nginx - Simple Resource Caching Sending nginx Logs to Loki with Grafana Alloy How to: Cisco ISE backup to SFTP repository with public key authentication Dummy IP & MAC Addresses for Documentation & Sanitization Deploying ISSO Commenting System for Static Content using Docker Generate a Vanity v3 Hidden Service Onion Address with mkp224o ssh-audit Primer - Audit your SSH Server mtr - More Detailed Traceroute - Network Troubleshooting My Personal Backup Strategy - August 2024 iperf3 - User Authentication with Password and RSA Public Keypair Adding a trash can to Linux with trash-cli Bandwidth Measurement using netcat on Linux Getting started with rsync - Comprehensive Guide Cron Jobs on Linux - Comprehensive Guide with Examples SSH Server Hardening Guide v2 Port Knocking with knockd and Linux - Server Hardening Getting started with rclone - Data transmission Getting started with dig - DNS troubleshooting Getting started with Fail2Ban on Linux Getting started with netcat on Linux with examples URL explained - The Fundamentals Troubleshooting Asking The Right Questions Create tmux layouts using bash scripts Getting started with tcpdump - Ittavern.com Curl on Linux - Reference Guide Getting started with nmap scripts My Offsite Backup - March 2023
Nginx - simple permanent or temporary redirects
2022-11-23 · via Ittavern.com

Temporary or permanent redirect #

First you have to decide whether the redirect will be permanent (301), or just temporary (302). If you are uncertain, just pick temporary and switch later.

Use cases from my understanding:

Permanent 301 redirects:
switching to another domain
merging multiple domains
switching from HTTP to HTTPs
better SEO experience
Temporary 302 redirect:
testing (A/B testing, etc)
single redirects to another domain
redirect to a maintenance page
redirect traffic for load balancing

Both do the same, but still have their use cases. Switching them up could cause problems with various indexes of search engines, SEO, wrongly being flagged as a spammer, and so on.

Simple redirects in nginx #

For this example, I am going to use temporary 302 redirects.

Simple redirect of a sub-domain to a single URL #

server {
    listen      80;
    listen      443;
    server_name  test2.brrl.net;
    location / {
          return 302 https://www.youtube.com/watch?v=dQw4w9WgXcQ;
    }
}

That is a simple redirect of the root of the sub-domain. Try it out: https://test2.brrl.net.

If you want to create a redirection of a subdirectory like /status, simply change it accordingly:

server {
    listen      80;
    listen      443;
    server_name  brrl.net;
    location /status {
          return 302 https://status.brrl.net/status/overview;
    }
}

With this config block, only the subdirectory /status would be redirected. For example: https://brrl.net/status redirects to https://status.brrl.net/status/overview.

other redirects #

There are many more forms of redirects, but I am familiar enough to write about that. I might add more redirects later on, but I'll have to test beforehand.