Derailleur mounting position I'm adapting a derailleur to a bike by welding it onto the dropout.

By looking at other bikes it seems to me there is not a very strict specification for where the derailleur hanger goes. It seems to vary.

Is there a range of placement with respect to the axle that I should observe? Is it ok to have the hanger in front of the axle, instead of behind it?
Welding is probably a bad idea - for several reasons.


Heat changes things - no doubt you have welding skills, but you'll know that relatively thin metals warp and bend and change their temper.   The thin metal of a derailleur will not take nicely to significant heat.  You also risk upsetting the thin-walled tube of your chain and seat stays.


1b. Many aluminium bikes are of a grade that can't be safely re-welded.  Eg, The 7005 grade is heat-treated after building, and re-heating it later will remove that leaving a softer section.


You're going to be limited to like-metals.  A modern derailleur will have aluminium construction with steel pins/axles.  An older or cheap/nasty derailleur will have more/all steel contstruction.   I'm no expert, but welding aluminium to steel isn't going to work, so at that point you'd need to braze instead.
Replacement - derailleurs aren't really high wear items and generally last tens of thousands of kilometres, but they do suffer damage in falls, and simple rough handling can whack the mech against things like rocks, other pedals, etc.   Having to grind off a derailleur to replace it would be a lot of work
Mechanical Fuse - in theory the hanger will bend before the frame breaks - this should allow damage to be reduced if there's something caught in the chain.  For me a hanger saved my frame when the chain snagged the derailleur and pulled it around the wheel and forward to the front derailleur.  Without a separate hanger, the frame would suffer more in an accident.
Function - almost every rear derailleur in the last 50 years uses a series of pivots to get the jockey wheels close to the rear cogs.  




There are Seven total... four pivots in the parallelogram, and one in each jockey wheel.  But the extra one is in the middle of the hanger's retaining bolt, and its not just a simple bolt

Heck its not even a simple pivot, instead its a spring-loaded pivot and I suspect this is the bit you want to weld to your frame.   This pivot point allows the entire rear mech to rotate down-and-aft as the chain climbs up to bigger cogs.  Without, the jockey wheel cage will start to hit the cassette, OR you have to weld it on so far backward that the chain will be extra long and slack.



Solutions

Instead of welding permanently, look to making a hanger.  Depending on the age of your frame, it could be a generic $5 item, or if its custom then they start getting silly-expensive.


Cheap generic claw hanger for a generic bike of the `80s.



These are cheap, and readily available.  You only need one, and it slides into the drive-side dropout that looks like a long slot, like this :



1b. If your frame had an integrated hanger like this then just use it to mount the derailleur.  Easy!



If someone has cut off an integrated hanger like this, then just use the claw adapter as per the first option. 

OR if you're a great welder, consider reinstating the hanger and fabbing the missing metal, hole and threads to attach to standard hanger bolts.  Do notice the wee lip at the bottom, that is for a screw to push on.


If your frame is more modern and doesn't have long slotty dropouts, like this:




Then you will have to either buy the right hanger, or engineer somethign that fits the interface in your bike's frame.  I needed a Cannondale one and it cost me $40 NZ (roughly 30 USD/ 25 euro)  There are silly amounts of different styles!   




Does your bike have track-ends like this: 



If so, your only option to add gears is to use an internally geared hub like a Shimano nexus 3/7/8 or Alfine 8/11 or a rohloff 14 speed, or one of the smaller 3 speed gear hubs.  

A frame with trackends tends to be too narrow for a modern wheel with cassette, so only has space for one rear cog.

I guess you could try designing and fabbing a hanger for a bike with trackends, but its a lot more than straight welding.

An IGH is a great solution here, but again they're not cheap and they look like motors.  But you can even get wireless DI2 capable ones for a sleek appearance and "I've got electronic gears" bragging rights.




Emergency hanger - these aren't great because the derailleur is held on by the wheel skewer/nut/QR, so its prone to move around.


However this would have saved me a long long walk had I carried one.



Again notice it has the same large hole with threads to take the main pivot bolt on a derailleur, and it has the step for the B tension screw to land on.


Last option is the easiest, but doesn't get you gears.  It is possible to run a bike with exactly one rear cog, and to pick the size based on your pedal cadence at full speed.  This is called a singlespeed and might be as simple as fitting a cassette with one cog and a lot of spacers, like this:




Chain tensioning might be fiddly if you lack long slots and can't mount a chain tensioner where the derailleur would go, and that loops us back around to the start.



In short: Welding on a derailleur is bad, so don't.