Advertisement
Guest User

Nginx config with git

a guest
Oct 4th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.26 KB | None | 0 0
  1. ===================================
  2. MAIN.conf
  3. ===================================
  4. server {
  5. #listen 80;
  6. #listen 443;
  7. #ssl on;
  8. #ssl_certificate /home/ssl/mycert.pem;
  9. #ssl_certificate_key /home/ssl/mycert.key;
  10. ssl_verify_client on;
  11.  
  12. listen 80 default_server;
  13. listen [::]:80 default_server;
  14.  
  15. # SSL configuration
  16.  
  17. listen 443 ssl default_server;
  18. listen [::]:443 ssl default_server;
  19.  
  20. root /var/www/html;
  21.  
  22. # Add index.php to the list if you are using PHP
  23. index index.html index.php;
  24.  
  25. server_name [site].me;
  26.  
  27. # hack for having custom error pages with images
  28.  
  29. error_page 404 /error/404.html;
  30. error_page 500 502 503 504 /error/50x.html;
  31.  
  32. location ^~ /error/ {
  33. alias /usr/share/nginx/errorPages/;
  34. internal;
  35. allow all;
  36. auth_basic off;
  37. }
  38.  
  39. location ^~ /errorassets/ {
  40. alias /usr/share/nginx/errorPages/errorassets/;
  41. allow all;
  42. auth_basic off;
  43. }
  44.  
  45. location / {
  46. # First attempt to serve request as file, then
  47. # as directory, then fall back to displaying a 404.
  48. try_files $uri $uri/ =404;
  49. }
  50.  
  51. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  52. #
  53. location ~ \.php$ {
  54. include snippets/fastcgi-php.conf;
  55.  
  56. fastcgi_pass unix:/var/run/php5-fpm.sock;
  57. }
  58.  
  59. # deny access to .htaccess files, if Apache's document root
  60. # concurs with nginx's one
  61.  
  62. location ~ /\.ht {
  63. deny all;
  64. }
  65. }
  66.  
  67. ===================================
  68. GIT1.conf
  69. ===================================
  70.  
  71. upstream gitlab-workhorse {
  72. server unix://var/opt/gitlab/gitlab-workhorse/socket fail_timeout=0;
  73. }
  74.  
  75. server {
  76. listen *:8080;
  77. server_name [site].me;
  78. server_tokens off;
  79. root /opt/gitlab/embedded/service/gitlab-rails/public;
  80.  
  81. client_max_body_size 250m;
  82.  
  83. access_log /var/log/gitlab/nginx/gitlab_access.log;
  84. error_log /var/log/gitlab/nginx/gitlab_error.log;
  85.  
  86. # Ensure Passenger uses the bundled Ruby version
  87. passenger_ruby /opt/gitlab/embedded/bin/ruby;
  88.  
  89. # Correct the $PATH variable to included packaged executables
  90. passenger_env_var PATH "/opt/gitlab/bin:/opt/gitlab/embedded/bin:/usr/local/bin:/usr/bin:/bin";
  91.  
  92. # Make sure Passenger runs as the correct user and group to
  93. # prevent permission issues
  94. passenger_user git;
  95. passenger_group git;
  96.  
  97. # Enable Passenger & keep at least one instance running at all times
  98. passenger_enabled on;
  99. passenger_min_instances 1;
  100.  
  101. location ~ ^/[\w\.-]+/[\w\.-]+/(info/refs|git-upload-pack|git-receive-pack)$ {
  102. # 'Error' 418 is a hack to re-use the @gitlab-workhorse block
  103. error_page 418 = @gitlab-workhorse;
  104. return 418;
  105. }
  106.  
  107. location ~ ^/[\w\.-]+/[\w\.-]+/repository/archive {
  108. # 'Error' 418 is a hack to re-use the @gitlab-workhorse block
  109. error_page 418 = @gitlab-workhorse;
  110. return 418;
  111. }
  112.  
  113. location ~ ^/api/v3/projects/.*/repository/archive {
  114. # 'Error' 418 is a hack to re-use the @gitlab-workhorse block
  115. error_page 418 = @gitlab-workhorse;
  116. return 418;
  117. }
  118.  
  119. # Build artifacts should be submitted to this location
  120. location ~ ^/[\w\.-]+/[\w\.-]+/builds/download {
  121. client_max_body_size 0;
  122. # 'Error' 418 is a hack to re-use the @gitlab-workhorse block
  123. error_page 418 = @gitlab-workhorse;
  124. return 418;
  125. }
  126.  
  127. # Build artifacts should be submitted to this location
  128. location ~ /ci/api/v1/builds/[0-9]+/artifacts {
  129. client_max_body_size 0;
  130. # 'Error' 418 is a hack to re-use the @gitlab-workhorse block
  131. error_page 418 = @gitlab-workhorse;
  132. return 418;
  133. }
  134.  
  135. location @gitlab-workhorse {
  136.  
  137. ## https://github.com/gitlabhq/gitlabhq/issues/694
  138. ## Some requests take more than 30 seconds.
  139. proxy_read_timeout 3600;
  140. proxy_connect_timeout 300;
  141. proxy_redirect off;
  142.  
  143. # Do not buffer Git HTTP responses
  144. proxy_buffering off;
  145.  
  146. #sub_filter_types text/html;
  147. #sub_filter '</head>' '\n<link rel="stylesheet" media="all" href="/custom/hexxgit.css" />\n</head>';
  148.  
  149. proxy_set_header Host $http_host;
  150. proxy_set_header X-Real-IP $remote_addr;
  151. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  152. proxy_set_header X-Forwarded-Proto $scheme;
  153.  
  154. proxy_pass http://gitlab-workhorse;
  155.  
  156. ## The following settings only work with NGINX 1.7.11 or newer
  157. #
  158. ## Pass chunked request bodies to gitlab-workhorse as-is
  159. # proxy_request_buffering off;
  160. # proxy_http_version 1.1;
  161. }
  162.  
  163. ## Enable gzip compression as per rails guide:
  164. ## http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
  165. ## WARNING: If you are using relative urls remove the block below
  166. ## See config/application.rb under "Relative url support" for the list of
  167. ## other files that need to be changed for relative url support
  168.  
  169. location ~ ^/(assets)/ {
  170. root /opt/gitlab/embedded/service/gitlab-rails/public;
  171. gzip_static on; # to serve pre-gzipped version
  172. expires max;
  173. add_header Cache-Control public;
  174. }
  175.  
  176. location / {
  177. # substitute just HTML items
  178. #sub_filter_types text/html;
  179. # replace the closing <head> tag with our custom CSS and JS
  180. sub_filter '</head>' '\n<link rel="stylesheet" media="all" href="/custom/hexxgit.css" />\n</head>';
  181.  
  182. # proxy all requests to the host `gitlab` this might be the only thing that needs to be customize in other setups
  183. #proxy_pass http://gitlab;
  184. # set the Host: header exactly how it was called
  185. #proxy_set_header Host $host;
  186. # don't let gitlab serve Nginx compressed (gzip/etc) since it won't be replaced above since the mime type won't match
  187. #proxy_set_header Accept-Encoding "";
  188. }
  189.  
  190. error_page 502 /502.html;
  191. }
  192.  
  193. ===================================
  194. GIT2.conf
  195. ===================================
  196.  
  197. server {
  198. listen 80;
  199. server_name git.hexxon.me;
  200.  
  201. location / {
  202. proxy_pass http://localhost:8080;
  203. }
  204. }r
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement