Advertisement
dganisha

my nginx conf

Mar 13th, 2022
385
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. server {
  2. listen 443 ssl http2;
  3. ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem; # managed by Certbot
  4. ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem; # managed by Certbot
  5. location ^/blog{
  6. root /var/www/html/mydomain.com/blog;
  7. index index.php;
  8. try_files $uri $uri/ /blog/index.php$is_args$args;
  9.  
  10. location ~ \.php$ {
  11. include snippets/fastcgi-php.conf;
  12. fastcgi_pass unix:/run/php/php7.4-fpm.sock;
  13. }
  14. }
  15. root /var/www/html/mydomain.com/my_laravel/public;
  16. index index.php index.html index.htm;
  17. error_log /var/log/nginx/mydomain.com.error.log;
  18. server_name mydomain.com www.mydomain.com;
  19. location / {
  20. try_files $uri $uri/ /index.php?$args;
  21. }
  22. if ($http_user_agent ~* (MJ12bot|SemrushBot|AhrefsBot|DotBot) ) { return 301 http://127.0.0.1/; }
  23. location ~ \.php$ {
  24. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  25. fastcgi_pass unix:/run/php/php7.4-mydomain.com-fpm.sock;
  26. fastcgi_index index.php;
  27. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  28. include fastcgi_params;
  29. }
  30. location = /favicon.ico {
  31. log_not_found off;
  32. access_log off;
  33. }
  34. location = /robots.txt {
  35. try_files $uri $uri/ /index.php?$args;
  36. allow all;
  37. log_not_found off;
  38. access_log off;
  39. }
  40. location ~ /\.ht {
  41. deny all;
  42. }
  43. location ~ /\.us {
  44. deny all;
  45. }
  46.  
  47. }
  48. server {
  49. if ($host = www.mydomain.com) {
  50. return 301 https://$host$request_uri;
  51. } # managed by Certbot
  52.  
  53.  
  54. if ($host = mydomain.com) {
  55. return 301 https://$host$request_uri;
  56. } # managed by Certbot
  57.  
  58. listen 80;
  59. server_name mydomain.com www.mydomain.com;
  60. return 404; # managed by Certbot
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement