Edit nginx.conf
vi /etc/nginx/nginx.conf
Inside http {} block, add
proxy_connect_timeout 1000s; proxy_send_timeout 1000s; proxy_read_timeout 1000s; fastcgi_send_timeout 1000s; fastcgi_read_timeout 1000s;
See nginx
Edit nginx.conf
vi /etc/nginx/nginx.conf
Inside http {} block, add
proxy_connect_timeout 1000s; proxy_send_timeout 1000s; proxy_read_timeout 1000s; fastcgi_send_timeout 1000s; fastcgi_read_timeout 1000s;
See nginx
Here is Nginx configuration for aMember script
location ~* ^/amember/.*\.(js|ico|gif|jpg|png|css|swf|csv)$ {} location ~* ^/amember/setup/index.php$ { try_files not-existing-file @php; } location ~* ^/amember/js.php { try_files not-existing-file @php; } location ~* ^/amember/index.php$ { try_files not-existing-file @php; } location ~* ^/amember/public.php$ { try_files not-existing-file @php; } location ~* ^/amember/public { rewrite ^.*$ /amember/public.php; } location ~* ^/amember/setup { rewrite ^.*$ /amember/setup/index.php; } location ~* ^/amember { rewrite ^.*$ /amember/index.php; } location ~* /amember/data/public/* {} location ~* /amember/data/.* {internal;} location ~ \.php$ { try_files not-existing-file @php; } location @php { fastcgi_pass 127.0.0.1:9000; include fastcgi_params; }
See Nginx
Redirect www domain to non-www
if ( $host != 'yourdomain.com' ) {
return 301 https://yourdomain.com$request_uri;
}
If you use custom ports, use
if ( $host != 'yourdomain.com' ) {
return 301 https://yourdomain.com:$server_port$request_uri;
}
Redirect Naked Domain to www
if ( $host != 'www.yourdomain.com' ) {
return 301 https://www.yourdomain.com$request_uri;
}
Redirect a site to HTTPS
server {
listen 80;
server_name DOMAIN_NAME www.DOMAIN_NAME;
return 301 https://$host$request_uri;
}
Here is a config with HTTP SSL verification
server {
listen 80;
server_name DOMAIN_NAME www.DOMAIN_NAME;
location ~ ^/.well-known/ {
allow all;
autoindex on;
root /var/www/html;
}
location / {
return 301 https://$host$request_uri;
}
}
Another way to redirect to HTTPS is by using
if ($scheme = http) {
return 301 https://$server_name$request_uri;
}
To redirect a specific URL to another URL
rewrite ^/phpmyadmin/$ http://13.54.176.201:8080/ permanent;
If you want to redirect a URL that matches a particular pattern, use
rewrite ^/phpmya.*$ http://13.54.176.201:8080/ permanent;
Back to Nginx
Nginx is a powerful open source web server that is known for its high performance, stability, and flexibility. It is used by millions of websites around the world, and it is a popular choice for web developers and system administrators who need a reliable and efficient way to serve web content.
Let’s say we have an Nginx virtual host like following
server {
listen 80;
root /var/www/html;
server_name serverok.in;
index index.htm index.html;
}
To make it SSL enabled, add the following to the server entry.
listen 443 ssl http2;
ssl_certificate /etc/ssl/serverok.crt;
ssl_certificate_key /etc/ssl/serverok.key;
ssl_client_certificate /etc/ssl/serverok.ca;
ssl_client_certificate introduced in Nginx version 1.19.4. If you are using an older version, add your ca-bundle after SSL certificate.
Example
server {
listen 80;
root /var/www/html;
server_name serverok.in;
index index.htm index.html;
listen 443 ssl http2;
ssl_certificate /etc/ssl/serverok.crt;
ssl_certificate_key /etc/ssl/serverok.key;
ssl_client_certificate /etc/ssl/serverok.ca;
location / {
try_files $uri/index.html $uri.html $uri;
}
}
ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1440m;
ssl_session_tickets off;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS";
Create
openssl dhparam -out /etc/ssl/dhparam.pem 2048
In your nginx config, add
ssl_dhparam /etc/ssl/dhparam.pem;
Redirect Traffic to SSL
server {
listen 80;
server_name www.serverok.in serverok.in;
return 301 https://serverok.in$request_uri;
}
If you don’t want to redirect SSL verification requests to HTTPS, use
server {
listen 80;
server_name DOMAIN_NAME;
location ~ ^/.well-known/ {
allow all;
autoindex on;
root /var/www/html;
}
location / {
return 301 https://DOMAIN_NAME$request_uri;
}
}
Disable TLSv1 in Nginx
Nginx Proxy SSL Verification
Nginx Redirect HTTP to HTTPS
See Nginx
To enable fcgi cache in Nginx, add the following code outside the server block.
fastcgi_cache_path /var/run/nginx-fastcgi-cache levels=1:2 keys_zone=SOKCACHE:60m inactive=60m; fastcgi_cache_key "$scheme$request_method$host$request_uri"; fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
Inside your location for .php files, above the proxy_pass, add
# cache start fastcgi_cache_bypass $skip_cache; fastcgi_no_cache $skip_cache; fastcgi_cache SOKCACHE; fastcgi_cache_valid 60m; add_header X-FastCGI-Cache $upstream_cache_status; # cache end
Add below code above .php location block
# Cache start set $skip_cache 0; if ($request_method = POST) { set $skip_cache 1; } if ($query_string != "") { set $skip_cache 1; } if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") { set $skip_cache 1; } if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { set $skip_cache 1; } # Cache end
This is used to skip FCGI cache for logged-in users.
Example
fastcgi_cache_path /var/run/nginx-fastcgi-cache levels=1:2 keys_zone=SOKCACHE:60m inactive=60m; fastcgi_cache_key "$scheme$request_method$host$request_uri"; fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_ignore_headers Cache-Control Expires Set-Cookie; server { listen 80; listen 443 ssl http2; ssl_certificate /etc/ssl/serverok.in.crt; ssl_certificate_key /etc/ssl/serverok.in.key; server_name serverok.in www.serverok.in; root /home/serverok.in/html/; index index.php index.html index.htm; access_log /var/log/nginx/serverok.in.log; error_log /var/log/nginx/serverok.in-error.log; client_max_body_size 1000M; proxy_read_timeout 600s; fastcgi_read_timeout 600s; fastcgi_send_timeout 600s; # Rewrites for Yoast SEO XML Sitemap rewrite ^/sitemap.xml$ /index.php?sitemap=1 last; rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last; rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last; # Forbidden files or directories location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|\.env) { return 404; } location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; try_files $uri /index.php?$args; } location = /xmlrpc.php { deny all; access_log off; log_not_found off; } # Cache start set $skip_cache 0; if ($request_method = POST) { set $skip_cache 1; } if ($query_string != "") { set $skip_cache 1; } if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") { set $skip_cache 1; } if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { set $skip_cache 1; } # Cache end location /nginx_status { stub_status; } location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_intercept_errors on; fastcgi_buffer_size 128k; fastcgi_buffers 256 16k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_send_timeout 600; fastcgi_read_timeout 600; fastcgi_param HTTP_PROXY ""; fastcgi_pass unix:/run/php/php-fpm-serverok.sock; # cache start fastcgi_cache_bypass $skip_cache; fastcgi_no_cache $skip_cache; fastcgi_cache SOKCACHE; fastcgi_cache_valid 60m; add_header X-FastCGI-Cache $upstream_cache_status; # cache end } location ~* \.(txt|xml|js)$ { expires max; log_not_found off; access_log off; } location ~* \.(css)$ { expires max; log_not_found off; access_log off; } location ~* \.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4|m4v|ogg|webm|aac|eot|ttf|otf|woff|svg)$ { expires max; log_not_found off; access_log off; } location ~* \.(jpg|jpeg|png|gif|swf|webp)$ { expires max; log_not_found off; access_log off; } location /wp-content/themes/understrap-child/.git/ { return 404; } gzip on; gzip_http_version 1.1; gzip_comp_level 5; gzip_min_length 256; gzip_proxied any; gzip_vary on; gzip_types application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component; }
Here is nginx configuration for wordpress
server { listen 80; server_name serverok.in www.serverok.in; root /var/www/html; index index.php; client_max_body_size 100M; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; proxy_read_timeout 180; fastcgi_intercept_errors on; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } location ~* \.(txt|xml|js)$ { expires max; log_not_found off; access_log off; } location ~* \.(css)$ { expires max; log_not_found off; access_log off; } location ~* \.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4|m4v|ogg|webm|aac|eot|ttf|otf|woff|svg)$ { expires max; log_not_found off; access_log off; } location ~* \.(jpg|jpeg|png|gif|swf|webp)$ { expires max; log_not_found off; access_log off; } gzip on; gzip_http_version 1.1; gzip_comp_level 5; gzip_min_length 256; gzip_proxied any; gzip_vary on; gzip_types application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component; }
Nginx Config with FCGI Cache + gzip compression
fastcgi_cache_path /tmp/nginx-cache levels=1:2 keys_zone=WORDPRESS:500m inactive=60m; fastcgi_cache_key "$scheme$request_method$host$request_uri"; fastcgi_cache_use_stale error timeout invalid_header http_500; server { listen *:443 ssl http2; server_name www.serverok.in serverok.in; root /var/www/html; index index.php; client_max_body_size 100M; location = /favicon.ico { log_not_found off; access_log off; } location = /robots.txt { allow all; log_not_found off; access_log off; } location / { try_files $uri $uri/ /index.php?$args; } #fastcgi_cache start set $no_cache 0; # POST requests and urls with a query string should always go to PHP if ($request_method = POST) { set $no_cache 1; } if ($query_string != "") { set $no_cache 1; } # Don't cache uris containing the following segments if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { set $no_cache 1; } # Don't use the cache for logged in users or recent commenters if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { set $no_cache 1; } location ~ \.php$ { include snippets/fastcgi-php.conf; proxy_read_timeout 180; fastcgi_intercept_errors on; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; fastcgi_cache_bypass $no_cache; fastcgi_no_cache $no_cache; fastcgi_cache WORDPRESS; fastcgi_cache_valid 200 60m; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } location ~* \.(txt|xml|js)$ { expires max; log_not_found off; access_log off; } location ~* \.(css)$ { expires max; log_not_found off; access_log off; } location ~* \.(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav|mp4|m4v|ogg|webm|aac|eot|ttf|otf|woff|svg)$ { expires max; log_not_found off; access_log off; } location ~* \.(jpg|jpeg|png|gif|swf|webp)$ { expires max; log_not_found off; access_log off; } ssl on; ssl_certificate /etc/ssl/serverok.in.crt; ssl_certificate_key /etc/ssl/serverok.in.key; # Enable HSTS. This forces SSL on clients that respect it, most modern browsers. The includeSubDomains flag is optional. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains"; # Set caches, protocols, and accepted ciphers. This config will merit an A+ SSL Labs score as of Sept 2015. ssl_session_cache shared:SSL:20m; ssl_session_timeout 10m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:ECDHE-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:CAMELLIA256-SHA:CAMELLIA128-SHA256; # Compression # Enable Gzip compressed. gzip on; # Enable compression both for HTTP/1.0 and HTTP/1.1. gzip_http_version 1.1; # Compression level (1-9). # 5 is a perfect compromise between size and cpu usage, offering about # 75% reduction for most ascii files (almost identical to level 9). gzip_comp_level 5; # Don't compress anything that's already small and unlikely to shrink much # if at all (the default is 20 bytes, which is bad as that usually leads to # larger files after gzipping). gzip_min_length 256; # Compress data even for clients that are connecting to us via proxies, # identified by the "Via" header (required for CloudFront). gzip_proxied any; # Tell proxies to cache both the gzipped and regular version of a resource # whenever the client's Accept-Encoding capabilities header varies; # Avoids the issue where a non-gzip capable client (which is extremely rare # today) would display gibberish if their proxy gave them the gzipped version. gzip_vary on; # Compress all output labeled with one of the following MIME-types. gzip_types application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component; } server { listen 80; server_name www.serverok.in serverok.in; return 301 https://serverok.in$request_uri; }
On Debian 9 server with nginx, i installed phpmyadmin with
apt install phpmyadmin
For some reason, ip-address/phpmyadmin did not work. On Ubuntu, it normally ask for for web server you have installed, then configure it during install.
I got this working by adding following code
location /phpmyadmin { root /usr/share/; location ~ ^/phpmyadmin/(.*\.php)$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } }
Inside default nginx virtual host
/etc/nginx/sites-available/default
Restart nginx with
service nginx restart
Now you will be able to access phpmyadmin with url
http://SERVER-IP-ADDR/phpmyadmin
Here is Nginx Configuration for vShare youtube clone script
# enforce NO www if ($host ~* ^www\.(.*)) { set $host_without_www $1; rewrite ^/(.*)$ https://$host_without_www/$1 permanent; } # main server location / { ## RewriteRule ^include/(.*) http://www.vshare.in rewrite ^/admin(.*)$ /index.php permanent; rewrite ^/admin/(.*)$ /index.php permanent; rewrite ^/install(.*)$ /index.php permanent; rewrite ^/install/(.*)$ /index.php permanent; rewrite ^/ubr(.*)$ /index.php permanent; rewrite ^/ubr/(.*)$ /index.php permanent; rewrite ^/cache/ /index.php permanent; rewrite ^/download/(.*) /download.php?video_id=$1 last; rewrite ^/view/(.*)/(.*)/ /view_video.php?id=$1 last; rewrite ^/view/(.*)/(.*) /view_video.php?id=$1 last; rewrite ^/view/(.*)/ /video_redirect.php?id=$1 last; rewrite ^/view/(.*) /video_redirect.php?id=$1 last; rewrite ^/tag/(.*)/(.*) /tag.php?search_string=$1&page=$2 last; rewrite ^/tags/ /tags.php last; rewrite ^/channels/ /channels.php last; rewrite ^/channels /channels.php last; rewrite ^/upload/success/(.*)/(.*)/ /upload_success.php?id=$1&upload_id=$2 last; rewrite ^/upload/embed/ /upload_embed.php last; rewrite ^/upload/embed /upload_embed.php last; rewrite ^/upload/ /upload.php last; rewrite ^/upload /upload.php last; rewrite ^/channel/(.*)/(.*)/recent/(.*)/ /video.php?category=recent&chid=$1&page=$3 last; rewrite ^/channel/(.*)/(.*)/viewed/(.*)/ /video.php?category=viewed&chid=$1&page=$3 last; rewrite ^/channel/(.*)/(.*)/(.*)/(.*) /video.php?chid=$1&category=$2&view_type=$3&page=$4 last; rewrite ^/channel/(.*)/(.*) /channel_details.php?id=$1 last; rewrite ^/friends/recommend/(.*)/ /recommend_friends.php?video_id=$1 last; rewrite ^/friends/invite/ /invite_friends.php?username=$1&page=$2 last; rewrite ^/friends/(.*) /friends.php?page=$1 last; rewrite ^/members/(.*)/(.*)/ /members.php?sort=$1&page=$2 last; rewrite ^/members/(.*) /members.php?page=$1 last; rewrite ^/detailed/recent/(.*) /video.php?category=recent&page=$1&view_type=detailed last; rewrite ^/detailed/viewed/(.*) /video.php?category=viewed&page=$1&view_type=detailed last; rewrite ^/detailed/discussed/(.*) /video.php?category=discussed&page=$1&view_type=detailed last; rewrite ^/detailed/favorites/(.*) /video.php?category=favorites&page=$1&view_type=detailed last; rewrite ^/detailed/rated/(.*) /video.php?category=rated&page=$1&view_type=detailed last; rewrite ^/detailed/featured/(.*) /video.php?category=featured&page=$1&view_type=detailed last; rewrite ^/recent/(.*) /video.php?category=recent&page=$1 last; rewrite ^/viewed/(.*) /video.php?category=viewed&page=$1 last; rewrite ^/edit/video/(.*) /video_edit.php?video_id=$1 last; rewrite ^/discussed/(.*) /video.php?category=discussed&page=$1 last; rewrite ^/favorites/(.*) /video.php?category=favorites&page=$1 last; rewrite ^/rated/(.*) /video.php?category=rated&page=$1 last; rewrite ^/featured/(.*) /video.php?category=featured&page=$1 last; rewrite ^/rss/new/ /rss.php?type=new last; rewrite ^/rss/comments/ /rss.php?type=comments last; rewrite ^/rss/views/ /rss.php?type=views last; rewrite ^/featured/(.*) /video.php?category=featured&page=$1 last; rewrite ^/group/new/ /group_new.php last; rewrite ^/group/(.*)/join/(.*) /group_invite_confirm.php?group_url=$1&key=$2 last; rewrite ^/group/(.*)/members/(.*) /group_members.php?group_url=$1&page=$2 last; rewrite ^/group/(.*)/videos/(.*) /group_videos.php?group_url=$1&page=$2 last; rewrite ^/group/(.*)/add/(.*) /group_add_videos.php?group_url=$1&page=$2 last; rewrite ^/group/(.*)/fav/(.*) /group_add_fav_videos.php?group_url=$1&page=$2 last; rewrite ^/group/(.*)/topic/(.*) /group_postss.php?group_url=$1&topic_id=$2 last; rewrite ^/group/(.*)/invite/(.*) /invite_members.php?group_url=$1 last; rewrite ^/group/(.*)/edit/(.*) /group_edit.php?group_url=$1 last; rewrite ^/group/(.*)/ /group_home.php?group_url=$1 last; rewrite ^/groups/(.*)/(.*)/(.*) /groups.php?chid=$1&page=$3 last; rewrite ^/groups/(.*)/(.*) /groups.php?chid=$1&page=$2 last; rewrite ^/login/ /login.php last; rewrite ^/login /login.php last; rewrite ^/logout/ /logout.php last; rewrite ^/logout /logout.php last; rewrite ^/signup/ /signup.php last; rewrite ^/signup /signup.php last; rewrite ^/family_filter/ /family_filter.php last; rewrite ^/family_filter /family_filter.php last; rewrite ^/pages/(.*).html /show_page.php?name=$1 last; rewrite ^/v/(.*)/ /video_embed.php?video_id=$1 last; rewrite ^/v/(.*) /video_embed.php?video_id=$1 last; rewrite ^/verify/user/(.*)/(.*)/(.*)/ /user_signup_verify.php?u=$1&i=$2&k=$3 last; rewrite ^/verify/email/(.*)/(.*)/(.*)/ /confirm_email.php?u=$1&i=$2&k=$3 last; rewrite ^/confirm/friend/(.*)/(.*) /friend_accept.php?id=$1&key=$2 last; rewrite ^/search/(.*)/(.*) /search_videos.php?search_string=$1&page=$2 last; rewrite ^/search/(.*) /search_videos.php?search_string=$1&page=1 last; rewrite ^/style/(.*)/ /style.php?css=$1 last; rewrite ^/style/(.*) /style.php?css=$1 last; rewrite ^/privacy/ /user_privacy.php?css=$1 last; rewrite ^/password/ /password_change.php last; rewrite ^/video_response_upload/(.*) /upload_video_response.php?vid=$1 last; rewrite ^/response/(.*)/videos/(.*) /video_responses.php?video_id=$1&page=$2 last; rewrite ^/verify/response/(.*)/(.*)/(.*)/ /video_response_verify.php?u=$1&i=$2&k=$3 last; rewrite ^/([^/\.]+)/account/ /myaccount.php last; rewrite ^/([^/\.]+)/favorites/(.*) /user_favorites.php?user_name=$1&page=$2 last; rewrite ^/([^/\.]+)/playlist/(.*)/(.*) /user_playlist.php?user_name=$1&page=$2 last; rewrite ^/([^/\.]+)/playlist/(.*) /user_playlist.php?user_name=$1&page=1 last; rewrite ^/([^/\.]+)/friends/videos/(.*) /user_friends_videos.php?user_name=$1&page=$2 last; rewrite ^/([^/\.]+)/friends/favorites/(.*) /user_friends_favourites.php?user_name=$1&page=$2 last; rewrite ^/([^/\.]+)/friends/(.*) /user_friends.php?user_name=$1&page=$2 last; rewrite ^/([^/\.]+)/pubic/(.*)$ /user_videos.php?user_name=$1&type=public&page=$2 last; rewrite ^/([^/\.]+)/private/(.*)$ /user_videos.php?user_name=$1&type=private&page=$2 last; rewrite ^/([^/\.]+)/groups/(.*)$ /user_groups.php?user_name=$1&page=$2 last; rewrite ^/([^/\.]+)/edit/(.*)$ /user_profile_edit.php?user_name=$1 last; rewrite ^/([^/\.]+)/unsubscribe/(.*)$ /email_unsubscribe.php?user_name=$1&vkey=$2 last; # Just in case we missed something :) error_page 404 /index.php?src=404; try_files $uri $uri/ =404; }
https://gist.github.com/serverok/1b300ff880db6aca59de0e42d86dadcb