Nessuna descrizione

enable_subpathing.sh.tpl 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #!/bin/bash
  2. cd frontend
  3. cd src
  4. cp App.jsx App.jsx.orig.`date -I`
  5. sed 's,startsWith("/,startsWith("SUBPATH/,g' -i App.jsx
  6. sed 's,path="/,path="SUBPATH/,g' -i App.jsx
  7. sed 's,location = "/,location = "SUBPATH/,g' -i App.jsx
  8. sed 's,window.location.origin;,"SUBPATH";,' -i App.jsx
  9. cd views
  10. for d in $(ls *.jsx); do cp $d $d.orig.`date -I`; done
  11. sed 's,pathname = "/,pathname = "SUBPATH/,g' -i *.jsx
  12. sed 's,navigate("/,navigate("SUBPATH/,g' -i *.jsx
  13. sed 's,navigate(`/,navigate(`SUBPATH/,g' -i *.jsx
  14. sed 's,href="/,href="SUBPATH/,g' -i *.jsx
  15. sed 's,path = "/,path = "SUBPATH/,g' -i *.jsx
  16. sed 's,link={"/,link={"SUBPATH/,g' -i *.jsx
  17. sed 's,to="/,to="SUBPATH/,g' -i *.jsx
  18. sed 's,to={"/,to={"SUBPATH/,g' -i *.jsx
  19. sed 's,${window.location.origin},SUBPATH,g' -i *.jsx
  20. cd ..
  21. cd components
  22. for d in $(ls *.jsx); do cp $d $d.orig.`date -I`; done
  23. sed 's,to="/,to="SUBPATH/,g' -i *.jsx
  24. sed 's,${window.location.origin},SUBPATH,g' -i *.jsx
  25. cd ../..
  26. cd confd/templates
  27. cp nginx.conf nginx.conf.orig.`date -I`
  28. sed 's,location / {,rewrite ^SUBPATH(/api/v1.*)$ $1 last;\n\n\t\tlocation / {,' -i nginx.conf
  29. cd ../..
  30. docker build -t ghcr.io/shuffle/shuffle-frontend:latest .
  31. cat << EOF
  32. If you want to reverse proxy shuffle using subpath "SUBPATH" you need to configure
  33. your web server - in this case nginx - to do the reverse proxying by at least adding
  34. location SUBPATH {
  35. proxy_pass http://snooss-proxy:3421/;
  36. rewrite SUBPATH/(.*)$ /$1 break;
  37. proxy_read_timeout 300s;
  38. # proxy header
  39. proxy_set_header Host $host;
  40. proxy_set_header X-Real-IP $remote_addr;
  41. proxy_set_header X-Forwarded-Proto $scheme;
  42. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  43. # substitute html content response
  44. proxy_set_header Accept-Encoding ""; # no compression allowed or sub_filter won't work
  45. sub_filter 'href="/' 'href="SUBPATH/';
  46. sub_filter 'href:"/' 'href:"SUBPATH/';
  47. sub_filter '/static' 'SUBPATH/static';
  48. sub_filter '/images' 'SUBPATH/images';
  49. sub_filter_types *;
  50. sub_filter_once off;
  51. }
  52. to your nginx configuration.
  53. EOF
  54. exit 0#!/bin/bash
  55. cd frontend
  56. cd src
  57. cp App.jsx App.jsx.orig.`date -I`
  58. sed 's,startsWith("/,startsWith("SUBPATH/,g' -i App.jsx
  59. sed 's,path="/,path="SUBPATH/,g' -i App.jsx
  60. sed 's,location = "/,location = "SUBPATH/,g' -i App.jsx
  61. sed 's,window.location.origin;,"SUBPATH";,' -i App.jsx
  62. cd views
  63. for d in $(ls *.jsx); do cp $d $d.orig.`date -I`; done
  64. sed 's,pathname = "/,pathname = "SUBPATH/,g' -i *.jsx
  65. sed 's,navigate("/,navigate("SUBPATH/,g' -i *.jsx
  66. sed 's,navigate(`/,navigate(`SUBPATH/,g' -i *.jsx
  67. sed 's,href="/,href="SUBPATH/,g' -i *.jsx
  68. sed 's,path = "/,path = "SUBPATH/,g' -i *.jsx
  69. sed 's,link={"/,link={"SUBPATH/,g' -i *.jsx
  70. sed 's,to="/,to="SUBPATH/,g' -i *.jsx
  71. sed 's,to={"/,to={"SUBPATH/,g' -i *.jsx
  72. sed 's,${window.location.origin},SUBPATH,g' -i *.jsx
  73. cd ..
  74. cd components
  75. for d in $(ls *.jsx); do cp $d $d.orig.`date -I`; done
  76. sed 's,to="/,to="SUBPATH/,g' -i *.jsx
  77. sed 's,${window.location.origin},SUBPATH,g' -i *.jsx
  78. cd ../..
  79. cd confd/templates
  80. cp nginx.conf nginx.conf.orig.`date -I`
  81. sed 's,location / {,rewrite ^SUBPATH(/api/v1.*)$ $1 last;\n\n\t\tlocation / {,' -i nginx.conf
  82. cd ../..
  83. docker build -t ghcr.io/shuffle/shuffle-frontend:latest .
  84. cat << EOF
  85. If you want to reverse proxy shuffle using subpath "SUBPATH" you need to configure
  86. your web server - in this case nginx - to do the reverse proxying by at least adding
  87. location SUBPATH {
  88. proxy_pass http://snooss-proxy:3421/;
  89. rewrite SUBPATH/(.*)$ /$1 break;
  90. proxy_read_timeout 300s;
  91. # proxy header
  92. proxy_set_header Host $host;
  93. proxy_set_header X-Real-IP $remote_addr;
  94. proxy_set_header X-Forwarded-Proto $scheme;
  95. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  96. # substitute html content response
  97. proxy_set_header Accept-Encoding ""; # no compression allowed or sub_filter won't work
  98. sub_filter 'href="/' 'href="SUBPATH/';
  99. sub_filter 'href:"/' 'href:"SUBPATH/';
  100. sub_filter '/static' 'SUBPATH/static';
  101. sub_filter '/images' 'SUBPATH/images';
  102. sub_filter_types *;
  103. sub_filter_once off;
  104. }
  105. to your nginx configuration.
  106. EOF
  107. exit 0