Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nginx short url redirection #2601

Open
Tealk opened this issue Feb 9, 2020 · 3 comments
Open

nginx short url redirection #2601

Tealk opened this issue Feb 9, 2020 · 3 comments
Labels
bug

Comments

@Tealk
Copy link

@Tealk Tealk commented Feb 9, 2020

Describe the bug
When calling a short URL I only get a 404
https://anzah.co/yourlsblog

Versions
nginx/1.14.2
PHP 7.4.2

I use Froxlor and this is the vhost:

server {
	listen 185.170.112.156:443 ssl http2;
	server_name anzah.co www.anzah.co;
	ssl_protocols TLSv1.2 TLSv1.3;
	ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
	ssl_prefer_server_ciphers off;
	ssl_session_tickets on;
	ssl_session_cache shared:SSL:10m;
	ssl_certificate /etc/ssl/froxlor-custom/anzah.co.crt;
	ssl_certificate_key /etc/ssl/froxlor-custom/anzah.co.key;
	add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload";
	ssl_stapling on;
	ssl_stapling_verify on;
	ssl_trusted_certificate /etc/ssl/froxlor-custom/anzah.co.crt;
	include /etc/nginx/vhost.d/acme.conf;
	access_log /dev/null combined;
	error_log /var/customers/logs/Anzah-anzah.co-error.log error;
	root /var/customers/webs/Anzah/anzah.co/;
	location / {
		index index.php index.html index.htm;
		try_files $uri $uri/ @rewrites;
	}

	location @rewrites {
		rewrite ^ /index.php last;
	}

	location ~ ^(.+?\.php)(/.*)?$ {
		try_files /d7dae490272ef73cd62b77297c9eb429.htm @php;
	}

	location @php {
		try_files $1 =404;
		include /etc/nginx/fastcgi_params;
		fastcgi_split_path_info ^(.+?\.php)(/.*)$;
		fastcgi_param SCRIPT_FILENAME $request_filename;
		fastcgi_param PATH_INFO $2;
		fastcgi_param HTTPS on;
		fastcgi_pass unix:/var/lib/fastcgi/1-anzah-anzah.co-php-fpm.socket;
		fastcgi_index index.php;
	}

	include vhost.d/secure-header.conf;
	include vhost.d/security_file_access.conf;
	include bots.d/ddos.conf;
	include bots.d/blockbots.conf;
}
@Tealk Tealk added the bug label Feb 9, 2020
@Tealk Tealk changed the title nginx short url nginx short url redirection Feb 13, 2020
@Tealk

This comment has been minimized.

Copy link
Author

@Tealk Tealk commented Feb 13, 2020

Fixed with this code:

if (!-e $request_filename){ rewrite ^(.+)$ /yourls-loader.php?q=$1 last; }

#1715 (comment)

@soldiweb

This comment has been minimized.

Copy link

@soldiweb soldiweb commented Feb 18, 2020

Hi Tealk, how do you put this code? I have the same problem on Nginx, thanks!

@Tealk

This comment has been minimized.

Copy link
Author

@Tealk Tealk commented Feb 18, 2020

simply into the location / block

	location / {
		index index.php index.html index.htm;
		try_files $uri $uri/ @rewrites;
		if (!-e $request_filename) {
			rewrite ^(.+)$ /yourls-loader.php?q=$1 last;
		}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.